コード例 #1
0
        public void should_throw_exception_when_passwords_dont_match()
        {
            var user = new User
            {
                Id       = 1,
                Username = "******",
                Password = "******"
            };

            _userDataAccess.CheckUserCredentials(
                Arg.Any <Npgsql.NpgsqlConnection>(),
                Arg.Any <int>(),
                Arg.Any <string>(),
                Arg.Any <string>(),
                Arg.Any <DateTime>(),
                Arg.Any <DateTime>()
                ).Returns(user);

            Random rnd = new Random();

            var id           = 1;
            var username     = "******";
            var password     = "******";
            var userId       = rnd.Next();
            var createdDate  = DateTime.Now;
            var lastActiveAt = DateTime.Now;

            var aus = new AuthorizeUserService(_dbConnection, _sessionDataAccess, _userDataAccess);

            Assert.Throws(Is.TypeOf <Exception>().And.Message.EqualTo("wrong credentials"), () => aus.GetSession(
                              id, userId, username, password, createdDate, lastActiveAt));
        }
コード例 #2
0
        public void should_throw_exception_when_password_is_empty_string()
        {
            Random rnd = new Random();

            var id           = rnd.Next();
            var username     = CredentialRandomUtil.GetRandomString();
            var password     = "";
            var userId       = rnd.Next();
            var createdDate  = DateTime.Now;
            var lastActiveAt = DateTime.Now;

            var aus = new AuthorizeUserService(_dbConnection, _sessionDataAccess, _userDataAccess);

            Assert.Throws(Is.TypeOf <Exception>().And.Message.EqualTo("empty password"), () => aus.GetSession(id, userId, username, password, createdDate, lastActiveAt));
        }