Beispiel #1
0
        public void Delete_WithNonExistingNews_ShouldDeleteTheNewsAndReturn404NotFound()
        {
            // Arrange
            var initialNew = new News()
            {
                Id = 1, Title = "Test news #1", Content = "Test content #1",
            };

            var controller = new NewsController(this.dataLayerMocked);

            this.SetupController(controller, "news");

            // Act
            this.dataLayerMocked.News.Add(initialNew);

            var httpGetResponse = controller.GetAllNews().ExecuteAsync(new CancellationToken()).Result;
            var newsFromService = httpGetResponse.Content.ReadAsAsync <List <News> >().Result;

            var newsId             = 3; // Non existing news
            var httpDeleteResponse = controller.DeleteNewById(newsId).ExecuteAsync(new CancellationToken()).Result;

            Assert.AreEqual(1, this.dataLayerMocked.News.All().Count());
            Assert.AreEqual(HttpStatusCode.NotFound, httpDeleteResponse.StatusCode);
        }