Beispiel #1
0
        public void verifyThatAfterCorrectingPropertiesAndUserValidNoErrorMessagesExist()
        {
            User                 user            = new User();
            UserRepository       repo            = new UserRepository();
            PasswordHasher       hasherAlgorithm = new HmacSha512Hasher();
            UserManagerViewModel target          = new UserManagerViewModel(user, repo, hasherAlgorithm);

            target.Username = "******";
            target.Password = "******";
            target.Realname = "Mig";
            target.AddUser();
            Assert.AreEqual(1, target.Users.Count, "Should have addded the user");

            //Test User - Fail
            target.Username = "******";
            target.Password = "******";
            target.IsUserValid();
            Assert.IsFalse(target.IsAuthenticated, "User should be invalid");
            Assert.IsFalse(String.IsNullOrEmpty((target as IDataErrorInfo).Error), "There should be an error message");

            //Test User - Pass
            target.Username = "******";
            target.Password = "******";
            target.IsUserValid();
            Assert.IsTrue(target.IsAuthenticated, "User should be valid");
            Assert.IsTrue(String.IsNullOrEmpty((target as IDataErrorInfo).Error), "There should not be an error message");
        }
Beispiel #2
0
        public void verifyUsernameIsInvalid()
        {
            User                 user            = new User();
            UserRepository       repo            = new UserRepository();
            PasswordHasher       hasherAlgorithm = new HmacSha512Hasher();
            UserManagerViewModel target          = new UserManagerViewModel(user, repo, hasherAlgorithm);

            target.Username = "******";
            target.Password = "******";
            target.Realname = "Mig";
            target.AddUser();
            Assert.AreEqual(1, target.Users.Count, "Should have addded the user");

            //User is clear
            Assert.IsTrue(String.IsNullOrEmpty(target.Username));
            Assert.IsTrue(String.IsNullOrEmpty(target.Password));
            Assert.IsTrue(String.IsNullOrEmpty(target.Realname));

            //Test User
            target.Username = "******";
            target.Password = "******";
            target.IsUserValid();
            Assert.IsFalse(target.IsAuthenticated, "User should be invalid");
            Assert.IsFalse(String.IsNullOrEmpty((target as IDataErrorInfo).Error), "There should be an error message");
        }