public void DeleteNonExistingNewsItemByID_ShouldReturnBadRequest() { var repo = new RepositoryMock(); var news = GetNewsItemsNews(); repo.Entities = news; var controller = new NewsController(repo); SetupController(controller, "news"); // Act var resultPostAction = controller.DeleteNewsItem(5).ExecuteAsync(new CancellationToken()).Result; // Assert Assert.AreEqual(HttpStatusCode.NotFound, resultPostAction.StatusCode); }
public void DeleteNonExistingNewsItemByID_ShouldReturnBadRequest() { var repo = new RepositoryMock(); var news = GetNewsItemsNews(); repo.Entities = news; var controller = new NewsController(repo); SetupController(controller, "news"); // Act var resultPostAction = controller.DeleteNewsItem(5).ExecuteAsync(new CancellationToken()).Result; // Assert Assert.AreEqual(HttpStatusCode.NotFound, resultPostAction.StatusCode); }
public void DeleteNewsItemByID_WithValidData_ShouldSucceed() { var repo = new RepositoryMock(); var news = GetNewsItemsNews(); repo.Entities = news; var controller = new NewsController(repo); SetupController(controller, "news"); // Act var resultPostAction = controller.DeleteNewsItem(news[2].Id).ExecuteAsync(new CancellationToken()).Result; // Assert Assert.AreEqual(HttpStatusCode.OK, resultPostAction.StatusCode); var content = resultPostAction.Content.ReadAsStringAsync().Result; var resultNews = JsonConvert.DeserializeObject<NewsItem>(content); }
public void DeleteNewsItemByID_WithValidData_ShouldSucceed() { var repo = new RepositoryMock(); var news = GetNewsItemsNews(); repo.Entities = news; var controller = new NewsController(repo); SetupController(controller, "news"); // Act var resultPostAction = controller.DeleteNewsItem(news[2].Id).ExecuteAsync(new CancellationToken()).Result; // Assert Assert.AreEqual(HttpStatusCode.OK, resultPostAction.StatusCode); var content = resultPostAction.Content.ReadAsStringAsync().Result; var resultNews = JsonConvert.DeserializeObject <NewsItem>(content); }