public GetWebsiteFilePaths ( string buildFolder ) : NuDeploy.Core.Services.Filesystem.RelativeFilePathInfo[] | ||
buildFolder | string | |
return | NuDeploy.Core.Services.Filesystem.RelativeFilePathInfo[] |
public void GetWebsiteFilePaths_FolderExist_ContainsOneWebsite_ResultCountEqualsFileCount_GetRelativeFilePathInfoIsCalledForEachFile() { // Arrange string buildFolder = Path.GetFullPath("build-folder"); string websitePath = Path.Combine( buildFolder, ConventionBasedBuildResultFilePathProvider.FolderNamePublishedWebsites, string.Format("Test.{0}.1", ConventionBasedBuildResultFilePathProvider.WebsiteFolderFragmentIdentifier)); var websiteFiles = new List<FileInfo> { new FileInfo(Path.Combine(websitePath, "file1.txt")), new FileInfo(Path.Combine(websitePath, "file2.txt")), }; var publishedWebApplicationDirectories = new List<DirectoryInfo> { new DirectoryInfo(websitePath) }; 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(websitePath)).Returns(websiteFiles); var relativeFilePathInfoFactory = new Mock<IRelativeFilePathInfoFactory>(); var buildResultFilePathProvider = new ConventionBasedBuildResultFilePathProvider(filesystemAccessor.Object, relativeFilePathInfoFactory.Object); // Act var result = buildResultFilePathProvider.GetWebsiteFilePaths(buildFolder); // Assert Assert.AreEqual(websiteFiles.Count, result.Length); foreach (var websiteFile in websiteFiles) { string absolutePath = websiteFile.FullName; relativeFilePathInfoFactory.Verify(r => r.GetRelativeFilePathInfo(absolutePath, It.IsAny<string>()), Times.Once()); } }
public void GetWebsiteFilePaths_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.GetWebsiteFilePaths(buildFolder); // Assert Assert.AreEqual(0, result.Length); }