コード例 #1
0
        public void HashedPasswordTrueTest()
        {
            var    password = "******";
            string hashed   = PasswordHasher.Hash(password);
            var    user     = new User()
            {
                Id       = 1,
                Name     = "John",
                Mail     = "*****@*****.**",
                Password = hashed
            };

            Users.Add(user);
            Context.SaveChanges();

            var query = new PasswordIsValidQuery()
            {
                Mail     = "*****@*****.**",
                Password = password
            };
            var handler = new PasswordIsValidQueryHandler(Context, PasswordHasher);
            var result  = handler.Handle(query, CancellationToken.None).Result;

            Assert.NotNull(result);
        }
コード例 #2
0
        public void NonExistantUserTest()
        {
            var    password = "******";
            string hashed   = PasswordHasher.Hash(password);

            var query = new PasswordIsValidQuery()
            {
                Mail     = "*****@*****.**",
                Password = password
            };
            var handler = new PasswordIsValidQueryHandler(Context, PasswordHasher);
            var result  = handler.Handle(query, CancellationToken.None).Result;

            Assert.Null(result);
        }