Created
February 10, 2011 12:25
-
-
Save GraemeF/820437 to your computer and use it in GitHub Desktop.
How can I check that "_log.Offset = newOffset" happened?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fake.GetCalls(_log). | |
Single(call => call.Method.Name == "set_Offset"). | |
GetArgument<TimeSpan>(0). | |
Should().Equal(newOffset); |
My attempt above was based on this issue report: http://code.google.com/p/fakeiteasy/issues/detail?id=14 (although my property has a getter too).
This should do what you want:
NextCall.To(_log).MustHaveHappened(Repeated.Once.Exactly);
_log.Offset = newOffset;
However, I'm slightly opinionated in this case and I would argue that in general it would be better to just check the value of the property (in NUnit):
Assert.That(_log.Offset, Is.EqualTo(newOffset));
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looking for the equivalent to Moq:
Mock.Get(_log).VerifySet(x => x.Offset = newOffset);
and NSubstitute:
_log.Received().Offset = newOffset;