public void WhenPostingAMessage_ReturnsNewPostCommand() { var codurer = new Codurer(new Mock<UserService>().Object); var postCommand = postCommandDescriptor.GetCommand(codurer, commandLine); postCommand.Should().BeOfType<PostCommand>(); }
public void WhenRetrievingTheWall_ReturnsNewWallCommand() { var codurer = new Codurer(new Mock<UserService>().Object); var postCommand = wallCommandDescriptor.GetCommand(codurer, commandLine); postCommand.Should().BeOfType<WallCommand>(); }
public void WhenRetrievingTheTimeline_ReturnsNewTimelineCommand() { var codurer = new Codurer(new Mock<UserService>().Object); var timelineCommand = timelineCommandDescriptor.GetCommand(codurer, commandLine); timelineCommand.Should().BeOfType<TimelineCommand>(); }
public void GivenThatAliceAndBobHavePostedAMessage_WhenBobSeeHisWall_BothMessagesAppears() { var userService = new Mock<UserService>(); var codurer = new Codurer(userService.Object); var alice = "Alice"; var aliceMessageText = "AliceMessage"; var aliceMessage = new Message(alice, aliceMessageText, DateTime.Now.AddMinutes(-5), null); var aliceMessages = new ReadOnlyCollection<Message>( new List<Message> { aliceMessage }); var bob = "Bob"; var bobMessageText = "Bob message"; var bobMessage = new Message(bob, bobMessageText, DateTime.Now.AddMinutes(-2), null); var bobMessages = new ReadOnlyCollection<Message>( new List<Message> { bobMessage }); userService.Setup(uService => uService.GetMessagesFrom(alice)).Returns(aliceMessages); userService.Setup(uService => uService.GetMessagesFromFollowingUsersFrom(alice)).Returns(bobMessages); codurer.Follow(alice, bob); IEnumerable<string> wall = codurer.GetWall(alice); wall.Should().HaveCount(2); wall.First().Should().Contain(bob); wall.Skip(1).Take(1).First().Should().Contain(alice); }
public void WhenFollowing_ReturnsNewFollowCommand() { var codurer = new Codurer(new Mock<UserService>().Object); var postCommand = followCommandDescriptor.GetCommand(codurer, commandLine); postCommand.Should().BeOfType<FollowCommand>(); }
public Command GetCommand(Codurer codurer, string commandLine) { string user = commandLine .Split(new string[] { "wall" }, StringSplitOptions.RemoveEmptyEntries) .Select(parameter => parameter.Trim()) .First(); return new WallCommand(codurer, user); }
public void TestInitialize() { codurer = new Codurer(UserServiceFactory.GetInMemoryUserService()); now = DateTime.Now; commandExecutor = new CommandExecutor(codurer, CommandDescriptorFactory.GetCommandDescriptors()); PostAliceMessages(); PostBobMessages(); }
public void WhenFollowingAUser_TheFollowerIsAddedToUsersFollowers() { var userService = new Mock<UserService>(); var codurer = new Codurer(userService.Object); var follower = "Alice"; var followed = "Bob"; codurer.Follow(follower, followed); userService.Verify(uService => uService.Follow(follower, followed)); }
public Command GetCommand(Codurer codurer, string commandLine) { string[] parameters = commandLine.Split(new string[] { "->" }, StringSplitOptions.RemoveEmptyEntries) .Select(parameter => parameter.Trim()) .ToArray<string>(); string user = parameters[0]; string message = parameters[1]; return new PostCommand(codurer, user, message); }
public Command GetCommand(Codurer codurer, string commandLine) { string[] parameters = commandLine .Split(new string[] { "follows" }, StringSplitOptions.RemoveEmptyEntries) .Select(parameter => parameter.Trim()) .ToArray<string>(); string user = parameters[0]; string following = parameters[1]; return new FollowCommand(codurer, user, following); }
public void GivenThatAliceHasPostedAMessage_WhenBobReadsAlice_TheMessageAppears() { var userService = new Mock<UserService>(); var codurer = new Codurer(userService.Object); var userName = "******"; var message = "new command (5 minutes ago)"; var messages = new ReadOnlyCollection<string>( new List<string>{ message }); userService.Setup(uService => uService.GetMessagesFormattedFrom(userName)).Returns(messages); IEnumerable<string> timeline = codurer.GetTimeline(userName); timeline.Should().HaveCount(1); timeline.First().Should().Be(message); }
public TimelineCommand(Codurer codurer, string user) { this.codurer = codurer; this.user = user; }
public FollowCommand(Codurer codurer, string user, string following) { this.codurer = codurer; this.user = user; this.following = following; }
public WallCommand(Codurer codurer, string user) { this.codurer = codurer; this.user = user; }
public void TestInitialize() { userService = new Mock<UserService>(); codurer = new Codurer(userService.Object); }
public PostCommand(Codurer codurer, string user, string message) { this.codurer = codurer; this.user = user; this.message = message; }
public CommandExecutor(Codurer codurer, List<CommandDescriptor> commandDescriptors) { this.codurer = codurer; this.commandDescriptors = commandDescriptors; }
public Command GetCommand(Codurer codurer, string commandLine) { string user = commandLine; return new TimelineCommand(codurer, user); }