예제 #1
0
 public void Validate(User user)
 {
     if (user.Username == "")
     {
         throw new ValidationException("Invalid username!");
     }
 }
예제 #2
0
        public void ValidateTest1()
        {
            User user = new User("");
            try
            {
                validator.Validate(user);
                Assert.AreEqual(1, 2);
            }
            catch (Exception)
            {
                Assert.AreEqual(1, 1);
            }

            user.Username = "******";

            try
            {
                validator.Validate(user);
                Assert.AreEqual(1, 1);
            }
            catch (Exception)
            {
                Assert.AreEqual(1, 2);
            }
        }
예제 #3
0
        public void UserTest()
        {
            User user = new User("username");

            //testing constructor
            Assert.AreEqual("username", user.Username);

            //testing get and set id
            user.Id = 1;
            Assert.AreEqual(1, user.Id);

            //testing get and set username
            user.Username = "******";
            Assert.AreEqual("test", user.Username);
        }
예제 #4
0
 public void Save(User user)
 {
     _userGenericRepository.Save(user);
 }