public void GetFeed_WithUnusedFeedId_Returns404(int nonExistantFeedId) { string inMemoryDatabaseName = $"GetFeed_WithUnusedFeedId_Returns404_{nonExistantFeedId}"; InsertMockFeedDataIntoInMemoryDatabase(inMemoryDatabaseName); using (var myInMemoryTechResourcesContext = InMemoryTechResourcesContext(inMemoryDatabaseName)) { FeedsController feedsController = GetNewFeedsController(myInMemoryTechResourcesContext); IActionResult actionResultFromController = feedsController.GetFeed(nonExistantFeedId).Result; Assert.IsType <NotFoundResult>(actionResultFromController); } }
public void GetFeed_WithExistingIntId_ReturnsCorrespondingFeed(int existingFeedId) { string inMemoryDatabaseName = $"GetFeed_WithExistingIntId_ReturnsCorrespondingFeed{existingFeedId}"; InsertMockFeedDataIntoInMemoryDatabase(inMemoryDatabaseName); using (var myInMemoryTechResourcesContext = InMemoryTechResourcesContext(inMemoryDatabaseName)) { FeedsController feedsController = GetNewFeedsController(myInMemoryTechResourcesContext); OkObjectResult actionResultFromController = (OkObjectResult)feedsController.GetFeed(existingFeedId).Result; Feed feedReturnedAsActionResultValue = (Feed)actionResultFromController.Value; Feed feedExpected = myInMemoryTechResourcesContext.Feed.Find(existingFeedId); Assert.Equal(feedExpected, feedReturnedAsActionResultValue); } }
public void GetFeed_WithNoArguments_ReturnsAllFeedItems() { string inMemoryDatabaseName = "GetFeed_WithNoArguments_ReturnsAllFeedItems"; InsertMockFeedDataIntoInMemoryDatabase(inMemoryDatabaseName); using (var myInMemoryTechResourcesContext = InMemoryTechResourcesContext(inMemoryDatabaseName)) { FeedsController feedsController = GetNewFeedsController(myInMemoryTechResourcesContext); IEnumerable <Feed> feeds = feedsController.GetFeed(); int NumberOfTotalFeeds = myInMemoryTechResourcesContext.Feed.Count(); int NumberOfFeedsReturned = feeds.Count(); Assert.Equal(NumberOfTotalFeeds, NumberOfFeedsReturned); } }