public async Task POST_IdentityLogs_Returns_Valid_List_Of_Downloadable_Items() { // Arrange ConfigureDownloadableFileController(); // Act IActionResult actualResult = await _TestDownloadableFileController.IdentityLogs("IdentityLogsPath"); Assert.NotNull(actualResult); var expectedViewResult = actualResult as ViewResult; Assert.NotNull(expectedViewResult); // Assert var actualDownloadableItems = expectedViewResult.Model as List <IDownloadableItem>; Assert.NotNull( actualDownloadableItems, "Expected the model to have returned an list of downloadable items [IEnumerable<IDownloadableItem>]"); Assert.AreEqual(3, actualDownloadableItems.Count, "Expected the tree configured items to have been returned"); IDownloadableItem fileOne = actualDownloadableItems.Find(x => x.Filepath == "file1"); Assert.NotNull(fileOne); Assert.AreEqual( "file1", fileOne.Filepath, "Expected file1 to have been returned as it was configured as a response at the beginning of this test"); }
public async Task POST_IdentityLogs_Defaults_To_Base_Logs_Path_When_Not_Provided(string filePath, string expectedPath) { // Arrange string actualPath = string.Empty; var configurableDownloadableFileBusinessLogic = new Mock <IDownloadableFileBusinessLogic>(); configurableDownloadableFileBusinessLogic .Setup(x => x.GetListOfDownloadableItemsFromPathAsync(It.IsAny <string>())) .Callback((string fp) => { actualPath = fp; }) .ReturnsAsync(new List <IDownloadableItem>()); var sharedBusinessLogic = IocContainer.Resolve <ISharedBusinessLogic>(); var webService = IocContainer.Resolve <IWebService>(); _TestDownloadableFileController = new DownloadableFileController( configurableDownloadableFileBusinessLogic.Object, null, webService, sharedBusinessLogic); // Act await _TestDownloadableFileController.IdentityLogs(filePath); // Assert Assert.AreEqual(expectedPath, actualPath); }