Exemplo n.º 1
0
 public void Validate(Author author)
 {
     if (author.Age < 0)
     {
         throw new ValidationException("Invalid age!");
     }
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 4
0
 public void Save(Author author)
 {
     _authorGenericRepository.Save(author);
 }