Register() public méthode

public Register ( ) : void
Résultat void
        public void ShouldRegisterUserIfUnique()
        {
            var repository = new Mock<IRepository>();

            var password = new Password {PasswordString = "abc"};
            var user = new User(new EmailAddress("*****@*****.**"), password, repository.Object);

            repository.Setup(rep => rep.LoadByEmailId(user.EmailAddress)).Returns(() => (User) null);
            repository.Setup(rep => rep.Save(user));

            user.Register();

            repository.VerifyAll();
        }
Exemple #2
0
        public void ShouldSaveAndLoadUser()
        {
            IRepository repository = new Repository();

            var password = new Password { PasswordString = "abc" };
            var email = new EmailAddress("*****@*****.**");
            var user = new User(email, password);

            user.FromMetro = true;
            user.RentPaid = 8000.00;

            user.Repository = repository;

            user.Register();

            User actualUser = repository.LoadByEmailId(email);

            Assert.IsNotNull(actualUser);
            Assert.AreEqual(email, actualUser.EmailAddress);
            Assert.AreEqual(user.FromMetro, actualUser.FromMetro);
            Assert.AreEqual(user.RentPaid, actualUser.RentPaid);
        }