Пример #1
0
 public void Test_CreateUserTwice()
 {
     //arrange
     var userRepository = new UsersRepository(_connectionString);
     var user = TestHelper.GenerateTestUser();
     //act
     userRepository.Create(user);
     userRepository.Create(user);
 }
Пример #2
0
 public void Test_DeleteUser()
 {
     //arrange
     var userRepository = new UsersRepository(_connectionString);
     var user = TestHelper.GenerateTestUser();
     userRepository.Create(user);
     //act
     userRepository.Delete(user.Id);
     //asserts
     userRepository.Get(user.Id);
 }
Пример #3
0
 public void Test_CreateAndGetUser()
 {
     //arrange
     var userRepository = new UsersRepository(_connectionString);
     var user = TestHelper.GenerateTestUser();
     //act
     userRepository.Create(user);
     var resultUser = userRepository.Get(user.Id);
     //asserts
     Assert.IsTrue(user.FirstName.Equals(resultUser.FirstName));
 }
Пример #4
0
 public void Test_GetAllUsers()
 {
     //arrange
     var userRepository = new UsersRepository(_connectionString);
     var user1 = TestHelper.GenerateTestUser();
     var user2 = TestHelper.GenerateTestUser();
     var user3 = TestHelper.GenerateTestUser();
     var user4 = TestHelper.GenerateTestUser();
     userRepository.Create(user1);
     userRepository.Create(user2);
     userRepository.Create(user3);
     userRepository.Create(user4);
     //act
     var users = userRepository.GetAllUsers();
     //asserts
     Assert.IsTrue(users.Count() == 4);
 }
 public void ShouldCreateUser()
 {
     //arrange
     var userRepository = new UsersRepository();
     var user = new User
     {
         Email = "*****@*****.**",
         FirstName = "name",
         LastName = "lastname",
         Id = Guid.NewGuid()
     };
     //act
     userRepository.Create(user);
     //asserts
     var resultUser = userRepository.Get(user.Id);
     Assert.AreEqual(user.Email, resultUser.Email);
 }
Пример #6
0
 public void Test_GetNotExistingUser()
 {
     //arrange
     var userRepository = new UsersRepository(_connectionString);
     var user = TestHelper.GenerateTestUser();
     //act
     userRepository.Get(user.Id);
 }
Пример #7
0
        public void Test_UserNameValidate()
        {
            //arrange
            var userRepository = new UsersRepository(_connectionString);
            List<String> goodNames = new List<string> { "goodName", "GOODNAME", "Имя", "NameИмя" };
            List<String> badNames = new List<string>
            {
                "badName ",
                "0badname",
                ".badname",
                "bad name",
                "qwertygugiopasdfghjklzqtgyuiopaswedfrtghygtfdcvbhgg",
                ""
            };

            //act, assert
            foreach (String name in goodNames)
                Assert.IsTrue(userRepository.ValidateUserName(name));
            foreach (String name in badNames)
                Assert.IsFalse(userRepository.ValidateUserName(name));
        }
Пример #8
0
 public void Test_UserInfoValidate()
 {
     //arrange
     var userRepository = new UsersRepository(_connectionString);
     var badUser = new User
     {
         Id = new Guid(),
         FirstName = "2",
         LastName = " ",
         Email = "login.host.com"
     };
     //act
     userRepository.ValidateUserInfo(badUser);
 }
Пример #9
0
        public void Test_UserEmailValidate()
        {
            //arrange
            var userRepository = new UsersRepository(_connectionString);
            List<String> goodEmails = new List<string> { "*****@*****.**", "*****@*****.**", "*****@*****.**" };
            List<String> badEmails = new List<string>
            {
                "bademail @mail.com",
                "bademailmail.com",
                " @mail.com",
                "email",
                " "
            };

            //act, assert
            foreach (String email in goodEmails)
                Assert.IsTrue(userRepository.ValidateUserEmail(email));
            foreach (String email in badEmails)
                Assert.IsFalse(userRepository.ValidateUserEmail(email));
        }