Example #1
0
        public void UseRepositoryWhenUserIsDeleted()
        {
            // arrange
            var email    = Email.Parse("*****@*****.**");
            var nickName = Nickname.Parse("nickname");
            var userId   = UserId.Parse("12345");

            var mockedUserRepository = UserRepositoryBuilder.Create();

            mockedUserRepository.Users.Add((email, nickName, userId));
            var userRepository = mockedUserRepository.Build();
            var userHandler    = new UserHandler(userRepository);

            // act
            userHandler.Handle(new UserDeleted(userId));
            // assert
            Assert.AreEqual(0, mockedUserRepository.Users.Count);
        }
Example #2
0
        public void UseRepositoryWhenUserIsCreated()
        {
            // arrange
            var email       = "*****@*****.**";
            var nickName    = "nickname";
            var userId      = "12345";
            var accessToken = "accessToken";

            var mockedUserRepository = UserRepositoryBuilder.Create();
            var userRepository       = mockedUserRepository.Build();
            var userHandler          = new UserHandler(userRepository);
            // act
            var identity = Identity.Parse(email, nickName, userId, accessToken);

            userHandler.Handle(new UserCreated(identity));
            // assert
            var(actualEmail, actualNickname, actualUserId) = mockedUserRepository.Users.First();
            Assert.AreEqual(Email.Parse(email), actualEmail);
            Assert.AreEqual(Nickname.Parse(nickName), actualNickname);
            Assert.AreEqual(UserId.Parse(userId), actualUserId);
        }