public void Should_show_each_post_with_most_recent_first_using_sequences() { var olderPost = new Post { DateTime = new DateTime(2010, 1, 1) }; var newerPost = new Post { DateTime = new DateTime(2010, 1, 2) }; var posts = new List<Post> { newerPost, olderPost }; var mockView = new Mock<BlogView>(); using (Sequence.Create()) { mockView.Setup(v => v.ShowPost(newerPost)).InSequence(); mockView.Setup(v => v.ShowPost(olderPost)).InSequence(); new BlogPresenter(mockView.Object).Show(posts); } }
public void Should_show_each_post_once_with_most_recent_first() { var olderPost = new Post { DateTime = new DateTime(2010, 1, 1) }; var newerPost = new Post { DateTime = new DateTime(2010, 1, 2) }; var posts = new List<Post> { newerPost, olderPost }; var mockView = new Mock<BlogView>(); var viewOrder = 0; mockView.Setup(v => v.ShowPost(newerPost)).Callback(() => Assert.That(viewOrder++, Is.EqualTo(0))); mockView.Setup(v => v.ShowPost(olderPost)).Callback(() => Assert.That(viewOrder++, Is.EqualTo(1))); new BlogPresenter(mockView.Object).Show(posts); mockView.Verify(v => v.ShowPost(newerPost), Times.Once()); mockView.Verify(v => v.ShowPost(olderPost), Times.Once()); }