public void PiecesWithTrailingSlashesAreIgnored() { bool interleaved; bool ignored = !Nupkg.IsValidPartName(Nupkg.GetLogicalPartName("foo.txt/[13].piece/", out interleaved).ToString()); Assert.True(ignored); }
public void PrependsSlash() { bool interleaved; string name = Nupkg.GetLogicalPartName("file1.xml", out interleaved).ToString(); Assert.False(interleaved); Assert.True(name.StartsWith("/", StringComparison.Ordinal)); }
public void UnderstandsNonInterleavedItems() { bool interleaved; string name = Nupkg.GetLogicalPartName("folder1/file1.xml", out interleaved).ToString(); Assert.False(interleaved); Assert.True(name.IndexOf("folder1/file1.xml", StringComparison.Ordinal) > 0); Assert.False(name.EndsWith("/", StringComparison.Ordinal)); }
public void ReturnsNothingForNoFilesAndNoFrameworkReferences() { // Arrange var fakeStream = CreateTestPackageStream(); var fakeNupkg = new Nupkg(fakeStream, leaveOpen: false); // Act var fx = fakeNupkg.GetSupportedFrameworks(); // Assert Assert.Empty(fx); }
public void ExtractTheManifest() { var packageStream = CreateTestPackageStream(); packageStream.Position = 0; // Act using (var nupkg = new Nupkg(packageStream, leaveOpen: false)) { Assert.Equal("TestPackage", nupkg.Metadata.Id); Assert.Equal(SemanticVersion.Parse("0.0.0.1"), nupkg.Metadata.Version); Assert.Equal("Trivial Description", nupkg.Metadata.Description); } }
public void ExtractThePartsList() { var packageStream = CreateTestPackageStream(); packageStream.Position = 0; // Act using (var nupkg = new Nupkg(packageStream, leaveOpen: false)) { var parts = nupkg.Parts; Assert.Contains("/[Content_Types].xml", parts); Assert.Contains("/_rels/.rels", parts); Assert.Contains("/TestPackage.nuspec", parts); Assert.Contains("/content/HelloWorld.cs", parts); } }
public void ReturnsFilePathFrameworksIfPresent(string directoryName, FrameworkName fxName) { // Arrange var fakeStream = CreateTestPackageStream(b => { b.Files.Add(CreateMockPackageFile(@"lib\" + directoryName + @"\file.dll")); }); var fakeNupkg = new Nupkg(fakeStream, leaveOpen: false); // Act var fx = fakeNupkg.GetSupportedFrameworks(); // Assert Assert.Equal(new[] { fxName, }, fx.ToArray()); }
public void ExtractTheFilesList() { var packageStream = CreateTestPackageStream(); packageStream.Position = 0; // Act using (var nupkg = new Nupkg(packageStream, leaveOpen: false)) { var files = nupkg.GetFiles(); Assert.DoesNotContain("/_rels/.rels", files); Assert.DoesNotContain("/[Content_Types].xml", files); Assert.DoesNotContain("_rels/.rels", files); Assert.DoesNotContain("[Content_Types].xml", files); Assert.Contains("TestPackage.nuspec", files); Assert.Contains("content/HelloWorld.cs", files); } }
private async Task EnsureNuGetExe() { if (await _fileStorageService.FileExistsAsync(Constants.DownloadsFolderName, "nuget.exe")) { // Ensure the file exists on blob storage. return; } var package = _packageService.FindPackageByIdAndVersion("NuGet.CommandLine", version: null, allowPrerelease: false); if (package == null) { throw new InvalidOperationException("Unable to find NuGet.CommandLine."); } using (Stream packageStream = await _packageFileService.DownloadPackageFileAsync(package)) { var nupkg = new Nupkg(packageStream, leaveOpen: true); await ExtractNuGetExe(nupkg); } }
public void ReturnsFrameworkAssemblyReferenceFrameworksIfNoFileFrameworks() { // Arrange var fakeStream = CreateTestPackageStream(b => { b.FrameworkReferences.Add(new FrameworkAssemblyReference("foo", new[] { VersionUtility.ParseFrameworkName("net45"), VersionUtility.ParseFrameworkName("sl-wp70") })); }); var fakeNupkg = new Nupkg(fakeStream, leaveOpen: false); // Act var fx = fakeNupkg.GetSupportedFrameworks(); // Assert Assert.Equal(new[] { new FrameworkName(".NETFramework, Version=4.5"), new FrameworkName("Silverlight, Version=v0.0, Profile=wp70") }, fx.ToArray()); }
public void ReturnsUnionOfFrameworkReferenceAndFileFrameworks() { // Arrange var fakeStream = CreateTestPackageStream(b => { b.Files.Add(CreateMockPackageFile(@"lib\net40\file.dll")); b.Files.Add(CreateMockPackageFile(@"lib\win\file.dll")); b.FrameworkReferences.Add(new FrameworkAssemblyReference("Windows", new[] { new FrameworkName("Windows, Version=0.0") })); b.FrameworkReferences.Add(new FrameworkAssemblyReference("System.Net.Http", new[] { new FrameworkName(".NETFramework, Version=2.0") })); }); var fakeNupkg = new Nupkg(fakeStream, leaveOpen: false); // Act var fx = fakeNupkg.GetSupportedFrameworks(); // Assert Assert.Equal(new[] { new FrameworkName("Windows, Version=0.0"), new FrameworkName(".NETFramework, Version=2.0"), new FrameworkName(".NETFramework, Version=4.0"), }, fx.ToArray()); }
public void ConvertsBackSlashesToSlashes() { var canon = Nupkg.CanonicalName(@"Dir1\Dir2\foo.txt"); Assert.Equal("Dir1/Dir2/foo.txt", canon); }
public void RemovesLeadingBackSlashes() { var canon = Nupkg.CanonicalName(@"\foo.txt"); Assert.Equal("foo.txt", canon); }
public void PartsWithDotOnlyISegmentsAreIgnored(string logicalPartName) { bool valid = Nupkg.IsValidPartName(logicalPartName); Assert.False(valid); }
public void PartsWithTrailingSlashesAreIgnored() { bool valid = Nupkg.IsValidPartName("/content/"); Assert.False(valid); }
public void EmptyPartNamesAreIgnored() { bool valid = Nupkg.IsValidPartName("/"); Assert.False(valid); }
public void LegitPartNamesAreAccepted(string logicalPartName) { bool valid = Nupkg.IsValidPartName(logicalPartName); Assert.True(valid); }