MustBeCalled() does not work with extension methods

2 posts, 0 answers
  1. Joel
    Joel avatar
    19 posts
    Member since:
    Dec 2011

    Posted 29 Dec 2011 Link to this post

    I setup two tests, one with MustBeCalled() and one with OccursNever(), but they both pass.

    Here's my tests...

    [TestMethod]
    public void MyClass_GetInt_with_MustBeCalled()
    {
        // Arrange
        var myClass = Mock.Create<MyClass>();
     
        Mock.Arrange(() => myClass.GetInt())
            .Returns(911)
            .MustBeCalled();
     
        // Act
        int result = myClass.GetInt();
     
        // Assert
        Assert.AreEqual(911, result);
        Mock.Assert(myClass);
    }
     
    [TestMethod]
    public void MyClass_GetInt_with_OccursNever()
    {
        // Arrange
        var myClass = Mock.Create<MyClass>();
     
        Mock.Arrange(() => myClass.GetInt())
            .Returns(911)
            .OccursNever();
     
        // Act
        int result = myClass.GetInt();
     
        // Assert
        Assert.AreEqual(911, result);
        Mock.Assert(myClass);
    }


    I uploaded a sample project here: http://dl.dropbox.com/u/1006254/JustMockTestProject2.zip
  2. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 03 Jan 2012 Link to this post

    Hi Joel,

    Thanks again for reporting the problem. Yes you are right and I was able to reproduce the problem. Should you need a fix for it urgently, please create a support ticket where I will send you the latest build of Telerik.JustMock.dll.

    I am also sending you some telerik points for pointing the issue out.

    Kind Regards,
    Mehfuz
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft R3 2016 release webinar banner
Back to Top