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>();
        }
示例#4
0
        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>();
        }
示例#6
0
        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();
        }
示例#8
0
        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));
        }
示例#9
0
        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);
        }
示例#10
0
        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);
        }
示例#11
0
        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);
        }
示例#12
0
 public TimelineCommand(Codurer codurer, string user)
 {
     this.codurer = codurer;
     this.user = user;
 }
示例#13
0
 public FollowCommand(Codurer codurer, string user, string following)
 {
     this.codurer = codurer;
     this.user = user;
     this.following = following;
 }
示例#14
0
 public WallCommand(Codurer codurer, string user)
 {
     this.codurer = codurer;
     this.user = user;
 }
示例#15
0
 public void TestInitialize()
 {
     userService = new Mock<UserService>();
     codurer = new Codurer(userService.Object);
 }
示例#16
0
 public PostCommand(Codurer codurer, string user, string message)
 {
     this.codurer = codurer;
     this.user = user;
     this.message = message;
 }
示例#17
0
 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);
 }