public void GivenManifestFileItCanRemoveEntryFromIt() { string manifestFile = Path.Combine(_testDirectoryRoot, _manifestFilename); _fileSystem.File.WriteAllText(manifestFile, _jsonContent); var toolManifestFileEditor = new ToolManifestEditor(_fileSystem); toolManifestFileEditor.Remove(new FilePath(manifestFile), new PackageId("dotnetsay")); _fileSystem.File.ReadAllText(manifestFile).Should().Be( @"{ ""version"": 1, ""isRoot"": true, ""tools"": { ""t-rex"": { ""version"": ""1.0.53"", ""commands"": [ ""t-rex"" ] } } }"); }
public void GivenManifestFileWhenRemoveNonExistPackageIdToolItThrows() { string manifestFile = Path.Combine(_testDirectoryRoot, _manifestFilename); _fileSystem.File.WriteAllText(manifestFile, _jsonContent); var toolManifestFileEditor = new ToolManifestEditor(_fileSystem); Action a = () => toolManifestFileEditor.Remove( new FilePath(manifestFile), new PackageId("non-exist")); a.ShouldThrow <ToolManifestException>() .And.Message.Should().Contain(string.Format( LocalizableStrings.CannotFindPackageIdInManifest, "non-exist")); _fileSystem.File.ReadAllText(manifestFile).Should().Be(_jsonContent); }
public void GivenAnInvalidManifestFileWhenRemoveItThrows() { string manifestFile = Path.Combine(_testDirectoryRoot, _manifestFilename); _fileSystem.File.WriteAllText(manifestFile, _jsonWithInvalidField); var toolManifestFileEditor = new ToolManifestEditor(_fileSystem); Action a = () => toolManifestFileEditor.Remove( new FilePath(manifestFile), new PackageId("dotnetsay")); a.ShouldThrow <ToolManifestException>() .And.Message.Should().Contain( string.Format(LocalizableStrings.InvalidManifestFilePrefix, manifestFile, string.Empty)); _fileSystem.File.ReadAllText(manifestFile).Should().Be(_jsonWithInvalidField); }