public GetWebApplicationFilePaths ( string buildFolder ) : NuDeploy.Core.Services.Filesystem.RelativeFilePathInfo[] | ||
buildFolder | string | |
return | NuDeploy.Core.Services.Filesystem.RelativeFilePathInfo[] |
public void GetWebApplicationFilePaths_FolderExist_ContainsOneApplication_ResultCountEqualsFileCount_GetRelativeFilePathInfoIsCalledForEachFile() { // Arrange string buildFolder = Path.GetFullPath("build-folder"); string webApplicationPath = Path.Combine(buildFolder, ConventionBasedBuildResultFilePathProvider.FolderNamePublishedWebsites, "Test.App.1"); var files = new List<FileInfo> { new FileInfo(Path.Combine(webApplicationPath, "file1.txt")), new FileInfo(Path.Combine(webApplicationPath, "file2.txt")), }; var publishedWebApplicationDirectories = new List<DirectoryInfo> { new DirectoryInfo(webApplicationPath) }; var filesystemAccessor = new Mock<IFilesystemAccessor>(); filesystemAccessor.Setup(f => f.DirectoryExists(It.Is<string>(s => s.StartsWith(buildFolder)))).Returns(true); filesystemAccessor.Setup(f => f.GetSubDirectories(It.Is<string>(s => s.StartsWith(buildFolder)))).Returns(publishedWebApplicationDirectories); filesystemAccessor.Setup(f => f.GetAllFiles(webApplicationPath)).Returns(files); var relativeFilePathInfoFactory = new Mock<IRelativeFilePathInfoFactory>(); var buildResultFilePathProvider = new ConventionBasedBuildResultFilePathProvider(filesystemAccessor.Object, relativeFilePathInfoFactory.Object); // Act var result = buildResultFilePathProvider.GetWebApplicationFilePaths(buildFolder); // Assert Assert.AreEqual(files.Count, result.Length); foreach (var websiteFile in files) { string absolutePath = websiteFile.FullName; relativeFilePathInfoFactory.Verify(r => r.GetRelativeFilePathInfo(absolutePath, It.IsAny<string>()), Times.Once()); } }
public void GetWebApplicationFilePaths_FolderExist_ButIsEmpty_ResultIsEmptyList() { // Arrange string buildFolder = Path.GetFullPath("build-folder"); var filesystemAccessor = new Mock<IFilesystemAccessor>(); filesystemAccessor.Setup(f => f.DirectoryExists(It.Is<string>(s => s.StartsWith(buildFolder)))).Returns(true); filesystemAccessor.Setup(f => f.GetSubDirectories(It.Is<string>(s => s.StartsWith(buildFolder)))).Returns(new List<DirectoryInfo>()); var relativeFilePathInfoFactory = new Mock<IRelativeFilePathInfoFactory>(); var buildResultFilePathProvider = new ConventionBasedBuildResultFilePathProvider(filesystemAccessor.Object, relativeFilePathInfoFactory.Object); // Act var result = buildResultFilePathProvider.GetWebApplicationFilePaths(buildFolder); // Assert Assert.AreEqual(0, result.Length); }