Пример #1
0
        public void ValidateTest2()
        {
            Article article = new Article("", "");
            try
            {
                validator.Validate(article);
                Assert.AreEqual(1, 2);
            }
            catch (Exception)
            {
                Assert.AreEqual(1, 1);
            }

            article.Title = "a";
            article.Content = "a";

            try
            {
                validator.Validate(article);
                Assert.AreEqual(1, 1);
            }
            catch (Exception)
            {
                Assert.AreEqual(1, 2);
            }
        }
Пример #2
0
        public void Validate(Article article)
        {
            if (article.Title == "")
            {
                throw new ValidationException("Invalid title!");
            }

            if (article.Content == "")
            {
                throw new ValidationException("Invalid content!");
            }
        }
Пример #3
0
        public void ArticleTest()
        {
            Article article = new Article("title","content");

            //testing constructor
            Assert.AreEqual("title", article.Title);
            Assert.AreEqual("content", article.Content);

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

            //testing set and get for Title
            article.Title = "test";
            Assert.AreEqual("test", article.Title);

            //testing set and get for Content
            article.Content = "test";
            Assert.AreEqual("test", article.Content);
        }
Пример #4
0
        private void AddNews()
        {
            String title;
            String content;

            Console.WriteLine("Titlul:");
            title = Console.ReadLine();

            Console.WriteLine("Content:");
            content = Console.ReadLine();

            Article article = new Article(title, content);

            try
            {
                manager.Save(article);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Пример #5
0
 public void Save(Article article)
 {
     _articleGenericRepository.Save(article);
 }