コード例 #1
0
        public async Task POST_WebsiteLogs_Returns_Valid_List_Of_Downloadable_Items()
        {
            // Arrange
            ConfigureDownloadableFileController();

            // Act
            IActionResult actualResult = await _TestDownloadableFileController.WebsiteLogs("WebsiteLogsPath");

            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 directoryOne = actualDownloadableItems.Find(x => x.Filepath == "Directory1");

            Assert.NotNull(directoryOne);
            Assert.AreEqual(
                "Directory1",
                directoryOne.Filepath,
                "Expected Directory1 to have been returned as it was configured as a response at the beginning of this test");
        }
コード例 #2
0
        public async Task POST_WebsiteLogs_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.WebsiteLogs(filePath);

            // Assert
            Assert.AreEqual(expectedPath, actualPath);
        }