public void Login_fails_with_empty_inputs()
        {
            var store = new Mock<IUserRegistrationStore>();
            var svc = new UserRegistrationService(store.Object);

            Assert.Throws<ArgumentNullException>(() => svc.Login("*****@*****.**", null));
            Assert.Throws<ArgumentNullException>(() => svc.Login(null, "password"));
        }
Exemplo n.º 2
0
        public void End_to_end_failed_login()
        {
            var store = new UserRegistrationStore();
            var svc = new UserRegistrationService(store);

            svc.Register("*****@*****.**", "password");

            Assert.Equal(Guid.Empty, svc.Login("*****@*****.**", "wrong"));
            Assert.Equal(Guid.Empty, svc.Login("*****@*****.**", "password"));
        }
        public void Service_can_verify_credentials()
        {
            var reg = new UserRegistration("*****@*****.**", "password");
            var store = new Mock<IUserRegistrationStore>();
            store.Setup(x => x.Load("*****@*****.**")).Returns(reg);
            var svc = new UserRegistrationService(store.Object);

            var result = svc.Login("*****@*****.**", "password");

            store.VerifyAll();
            Assert.Equal(reg.Id, result);
        }
        public void Login_fails_with_wrong_password()
        {
            var reg = new UserRegistration("*****@*****.**", "password");
            var store = new Mock<IUserRegistrationStore>();
            store.Setup(x => x.Load("*****@*****.**")).Returns(reg);
            var svc = new UserRegistrationService(store.Object);

            var result = svc.Login("*****@*****.**", "wrong");

            store.VerifyAll();
            Assert.NotEqual(reg.Id, result);
            Assert.Equal(new Guid(), result);
        }
Exemplo n.º 5
0
        public void End_to_end_success()
        {
            var store = new UserRegistrationStore();
            var svc = new UserRegistrationService(store);

            svc.Register("*****@*****.**", "password");

            var id = svc.Login("*****@*****.**", "password");
            Assert.NotEqual(Guid.Empty, id);

            var user = store.Users.FirstOrDefault(x => x.Id == id);
            Assert.Equal("*****@*****.**", user.Email);
        }