public void OutputsPostsInDescendingTimestampOrder() { var alice = new User("Alice"); var bob = new User("Bob"); var charlie = new User("Charlie"); alice.Follow(bob); alice.Follow(charlie); var posts = new[] { new Post(bob, "Hello, world!", DateTime.MinValue), new Post(charlie, "Bonjour la monde!", DateTime.MinValue.AddYears(1)), new Post(bob, "Sekai, konnichiwa!", DateTime.MinValue.AddYears(2)) }; bob.Publish(posts[0]); bob.Publish(posts[2]); charlie.Publish(posts[1]); var outputSpy = new OutputSpy(); var postFormatter = new PostFormatterDummy(p => p.Message); var command = new PrintWall(postFormatter, outputSpy); command.Execute(alice); Assert.Equal( new[] { "Sekai, konnichiwa!", "Bonjour la monde!", "Hello, world!" }, outputSpy.CalledWith); }
public void PrintsTheFormattedStrings() { var user = new User("Alice"); user.Publish(new Post(user, "", DateTime.Now)); var spy = new OutputSpy(); var command = new PrintPosts(new PostFormatterDummy("Hello, World!"), spy); command.Execute(user); Assert.Equal(new[] { "Hello, World!" }, spy.CalledWith); }
public void CallsThePrintFormatter() { var user = new User("Alice"); var post = new Post(user, "Hello!", DateTime.Now); user.Publish(post); var spy = new PostFormatterSpy(); var oSpy = new OutputSpy(); var command = new PrintPosts(spy, oSpy); command.Execute(user); Assert.Equal(new[] { post }, spy.CalledWith); }
public void OutputsFormattedStrings() { var alice = new User("Alice"); var bob = new User("Bob"); var post = new Post(bob, "Hello, World!", DateTime.Now); alice.Follow(bob); bob.Publish(post); var outputSpy = new OutputSpy(); var postFormatter = new PostFormatterDummy("Hello!"); var command = new PrintWall(postFormatter, outputSpy); command.Execute(alice); Assert.Equal(new[] { "Hello!" }, outputSpy.CalledWith); }
public void PrintsInDescendingTimestampOrder() { var user = new User("Alice"); var posts = new[] { new Post(user, "Hello, world!", DateTime.MinValue), new Post(user, "Bonjour la monde!", DateTime.MinValue.AddYears(1)), new Post(user, "Sekai, konnichiwa!", DateTime.MinValue.AddYears(2)) }; user.Publish(posts[0]); user.Publish(posts[1]); user.Publish(posts[2]); var spy = new OutputSpy(); var command = new PrintPosts(new PostFormatterDummy(p => p.Message), spy); command.Execute(user); Assert.Equal( new[] { "Sekai, konnichiwa!", "Bonjour la monde!", "Hello, world!" }, spy.CalledWith); }