예제 #1
0
 public void Validate(Author author)
 {
     if (author.Age < 0)
     {
         throw new ValidationException("Invalid age!");
     }
 }
예제 #2
0
        public void ValidateTest()
        {
            Author author = new Author("ad",-1);
            try
            {
                validator.Validate(author);
                Assert.AreEqual(1, 2);
            }
            catch (Exception)
            {
                Assert.AreEqual(1, 1);
            }

            author.Age = 45;

            try
            {
                validator.Validate(author);
                Assert.AreEqual(1,1);
            }
            catch (Exception)
            {
                Assert.AreEqual(1,2);
            }
        }
예제 #3
0
        public void AuthorTest()
        {
            Author author = new Author("name", 21);

            //testing the constructor
            Assert.AreEqual("name", author.Name);
            Assert.AreEqual(21, author.Age);

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

            //testing get and set for name
            author.Name = "test";
            Assert.AreEqual("test", author.Name);

            //testing get and set for age
            author.Age = 1;
            Assert.AreEqual(1, author.Age);
        }
예제 #4
0
 public void Save(Author author)
 {
     _authorGenericRepository.Save(author);
 }