예제 #1
0
 public void CreateNewUser_Succeeds()
 {
     try
     {
         // arrange + act
         _sutNoValidation.CreateUser(new User("testUserName", "testPwd"));
     }
     catch (Exception ex)
     {
         // assert
         Assert.Fail("Expected no exception, but got: " + ex.Message);
     }
 }
예제 #2
0
        public void CreateNewUser_UserNameValidationFails_2()
        {
            //	custom validation checks for UserName: should be a valid active directory account (domain\username)

            // arrange
            var sutWithADValidation = new UserAuthManager(new SqlUserRepository(_connectionString), new List <IValidation <User> > {
                new UserNameIsValidActiveDirectoryAccountValidation()
            });

            try
            {
                // act
                sutWithADValidation.CreateUser(new User("notAValidADAccount", "somePwd"));
                Assert.Fail("Expected exception on the previous line.");
            }
            catch (Exception ex)
            {
                // assert
                Assert.IsInstanceOfType(ex, typeof(ValidationException));
                Assert.AreEqual(new UserNameIsValidActiveDirectoryAccountValidation().Message, ex.Message);
            }
        }