public void GivenManifestFileInDifferentDirectoriesWhenFindContainPackageIdItCanGetResultInOrder() { var subdirectoryOfTestRoot = Path.Combine(_testDirectoryRoot, "sub"); _fileSystem.Directory.CreateDirectory(subdirectoryOfTestRoot); string manifestFileInParentDirectory = Path.Combine(_testDirectoryRoot, _manifestFilename); _fileSystem.File.WriteAllText(manifestFileInParentDirectory, _jsonContentInParentDirectory); string manifestFileInSubDirectory = Path.Combine(subdirectoryOfTestRoot, _manifestFilename); _fileSystem.File.WriteAllText(manifestFileInSubDirectory, _jsonContentInCurrentDirectory); var toolManifest = new ToolManifestFinder( new DirectoryPath(subdirectoryOfTestRoot), _fileSystem, new FakeDangerousFileDetector()); var manifests = toolManifest.FindByPackageId(new PackageId("t-rex")); manifests.Should().ContainInOrder(new List <FilePath> { new FilePath(manifestFileInSubDirectory), new FilePath(manifestFileInParentDirectory) }, "Order matters, the closest to probe start first."); var manifests2 = toolManifest.FindByPackageId(new PackageId("dotnetsay")); manifests2.Should().ContainInOrder(new List <FilePath> { new FilePath(manifestFileInSubDirectory) }); var manifests3 = toolManifest.FindByPackageId(new PackageId("non-exist")); manifests3.Should().BeEmpty(); }
public void GivenNoManifestFileWhenFindContainPackageIdItThrows() { var subdirectoryOfTestRoot = Path.Combine(_testDirectoryRoot, "sub"); _fileSystem.Directory.CreateDirectory(subdirectoryOfTestRoot); var toolManifest = new ToolManifestFinder( new DirectoryPath(subdirectoryOfTestRoot), _fileSystem, new FakeDangerousFileDetector()); Action a = () => toolManifest.FindByPackageId(new PackageId("t-rex")); a.ShouldThrow <ToolManifestCannotBeFoundException>().And.Message.Should() .Contain(LocalizableStrings.CannotFindAManifestFile); a.ShouldThrow <ToolManifestCannotBeFoundException>().And.VerboseMessage.Should() .Contain(string.Format(LocalizableStrings.ListOfSearched, "")); }