public async Task GetPublisher_NonexistentZeroId_NotFoundResult() { // Arrange const int publisherId = 0; InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList()); // Act using (var context = new GameReviewsContext(options)) { PublishersController publishersController = new PublishersController(context); var result = (await publishersController.GetPublisher(publisherId)).Result; // Assert Assert.IsType <NotFoundResult>(result); } }
public async Task GetPublisher_ExistingId_TaskActionResultContainsPublisher() { // Arrange const int publisherId = 3; Publisher expectedPublisher = GetFakeList().Where(d => d.ID == publisherId).FirstOrDefault(); InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, GetFakeList()); // Act using (var context = new GameReviewsContext(options)) { PublishersController publishersController = new PublishersController(context); var actionResult = (await publishersController.GetPublisher(publisherId)); Publisher publisher = actionResult.Value; ActionResult result = actionResult.Result; // Assert Assert.True(AreEqual(expectedPublisher, publisher)); Assert.IsNotType <NotFoundResult>(result); } }