Ejemplo n.º 1
0
        public void UsernameWallPrintsWall()
        {
            var alice = new User("Alice");
            var retriever = new StubUserRetriever(alice);

            var spy = new PrintPostsSpy();
            var pSpy = new PublishPostSpy();
            var fSpy = new FollowUserSpy();
            var wSpy = new PrintWallSpy();
            var dispatcher = new CommandDispatcher(retriever, spy, pSpy, fSpy, wSpy);
            dispatcher.Run(new[] { "Alice", "wall" });

            Assert.Equal(alice, wSpy.LastCalledWith);
        }
Ejemplo n.º 2
0
        public void UsernameArrowMessagePublishesMessage()
        {
            var alice = new User("Alice");
            var retriever = new StubUserRetriever(alice);

            var spy = new PrintPostsSpy();
            var pSpy = new PublishPostSpy();
            var fSpy = new FollowUserSpy();
            var wSpy = new PrintWallSpy();
            var dispatcher = new CommandDispatcher(retriever, spy, pSpy, fSpy, wSpy);
            dispatcher.Run(new[] { "Alice", "->", "Hello,", "World!" });

            Assert.Equal(alice, pSpy.UserCalledWith);
            Assert.Equal("Hello, World!", pSpy.MessageCalledWith);
        }
Ejemplo n.º 3
0
        public void UsernameFollowUsernameFollowsUser()
        {
            var alice = new User("Alice");
            var bob = new User("Bob");
            var repo = new UserRepository();
            repo.Add(alice);
            repo.Add(bob);
            var retriever = new CreateOrRetrieveUserByName(repo);

            var spy = new PrintPostsSpy();
            var pSpy = new PublishPostSpy();
            var fSpy = new FollowUserSpy();
            var wSpy = new PrintWallSpy();
            var dispatcher = new CommandDispatcher(retriever, spy, pSpy, fSpy, wSpy);
            dispatcher.Run(new[] { "Alice", "follows", "Bob" });

            Assert.Equal(alice, fSpy.UserCalledWith);
            Assert.Equal(bob, fSpy.UserToFollowCalledWith);
        }