예제 #1
0
        public void RetrievesUserByName()
        {
            var repo = new UserRepository();
            var alice = new User("Alice");
            repo.Add(alice);

            Assert.Equal(alice, repo.Get("Alice"));
        }
예제 #2
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);
        }