public void TestAddInvalidNews()
        {
            var controller = new NewsController(repoMock.Object);
            SetupController(controller, "News");

            var invalidNews = new NewsBindingModel { Title = "No content" };

            // it's not the controller's job to validate - there is a validator
            controller.ModelState.AddModelError("Content", "Required");
            var result = controller.AddNews(invalidNews).ExecuteAsync(new CancellationToken()).Result;
            Assert.AreEqual(HttpStatusCode.BadRequest, result.StatusCode);
        }
        public void TestAddValidNews()
        {
            var controller = new NewsController(repoMock.Object);
            SetupController(controller, "News");

            var news = new List<News>
            {
                new News { Title = "Zaglavie", Content = "dadadada" },
                new News { Title = "Asdjoqwe", Content = "asodojk" }
            };

            repoMock.Setup(repo => repo.Add(It.IsAny<News>())).Callback((News n) => news.Add(n));

            var newNews = new NewsBindingModel { Title = "Teadsad", Content = "koko6ki" };
            var result = controller.AddNews(newNews).ExecuteAsync(new CancellationToken()).Result;

            Assert.AreEqual(HttpStatusCode.Created, result.StatusCode);
            Assert.AreEqual(newNews.Title, news.Last().Title);
            Assert.AreEqual(newNews.Content, news.Last().Content);
            Assert.IsNotNull(news.Last().PublishDate);
        }