public async Task DeletePublisher_NegativeId_NotFoundResult() { // Arrange const int publisherIdToDelete = -10; InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList()); Publisher expectedPublisher = GetFakeList().Where(d => d.ID == publisherIdToDelete).FirstOrDefault(); // Act using (var context = new GameReviewsContext(options)) { PublishersController publishersController = new PublishersController(context); var actionResult = (await publishersController.DeletePublisher(publisherIdToDelete)); var result = actionResult.Result; // Assert Assert.IsType <NotFoundResult>(result); } }
public async Task DeletePublisher_ExistingId_TaskActionResultContainsDeletedPublisher() { // Arrange const int publisherIdToDelete = 3; InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList()); Publisher expectedPublisher = GetFakeList().Where(d => d.ID == publisherIdToDelete).FirstOrDefault(); // Act using (var context = new GameReviewsContext(options)) { PublishersController publishersController = new PublishersController(context); var actionResult = (await publishersController.DeletePublisher(publisherIdToDelete)); var result = actionResult.Result; Publisher actualPublisher = actionResult.Value; // Assert Assert.IsNotType <NotFoundResult>(result); Assert.True(context.Publishers.Find(publisherIdToDelete) == null); Assert.True(AreEqual(expectedPublisher, actualPublisher)); } }