Created
April 1, 2014 15:09
-
-
Save rofr/9916118 to your computer and use it in GitHub Desktop.
First attempt, well almost, at using FakeItEasy
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
| [Test] | |
| public void Timestamp_is_transfered_to_journalentry() | |
| { | |
| JournalEntry entry = null; | |
| var fake = A.Fake<IJournalWriter>(); | |
| A.CallTo(() => fake.Write(A<JournalEntry>._)) | |
| .Invokes((JournalEntry je) => | |
| { | |
| entry = je; | |
| }); | |
| var command = new SetTimeCommand(); | |
| command.Timestamp = DateTime.Now; | |
| var target = new JournalAppender(0, fake); | |
| target.Append(command); | |
| Assert.IsNotNull(entry); | |
| Assert.AreEqual(command.Timestamp, entry.Created); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks good. An alternative may be
Of course, I am not a compiler, so I may be slightly off.
It at least partly comes down to whether you prefer NUnit's messages or FakeItEasy's.
In this case, though, I think the
MustHaveHappenedis more intention-revealing than theInvokesand the extraentryvariable.