This is a migrated thread and some comments may be shown as answers.

MustBeCalled() does not work with extension methods

1 Answer 52 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 1
Joel asked on 29 Dec 2011, 09:52 PM
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

1 Answer, 1 is accepted

Sort by
0
Ricky
Telerik team
answered on 03 Jan 2012, 01:43 PM
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 >>

Tags
General Discussions
Asked by
Joel
Top achievements
Rank 1
Answers by
Ricky
Telerik team
Share this question
or