Rhino Mocks 3.5 Verify that the property adjuster was not called

Is it possible to verify that the property adjuster was not called using Rhino Mocks 3.5?

+3
source share
2 answers

It is possible:

public class OneProperty
{
    virtual public int MyInt
    {
        get;
        set;
    }
}

[Test]
public void IntWasSet()
{
    var prop = Rhino.Mocks.MockRepository.GenerateMock<OneProperty>();

    prop.MyInt = 5;

    prop.AssertWasNotCalled(x => x.MyInt = Arg<int>.Is.Anything);

    prop.VerifyAllExpectations();
}

Running this test on Rhino Mocks 3.5 results in the following error:

Errors and failures: 1) Test error: InterfacerTests.TestMatchesInterface.IntWasSet Rhino.Mocks.Exceptions.ExpectationViolationException: OneProperty.set_MyInt is expected (nothing); would not be called, but it was found on actual calls made to a mock object.

I discovered the syntax Arg<T>

+5
source

. , , , , . Rhino Mocks.

+2

Source: https://habr.com/ru/post/1746991/


All Articles