public void GetPackageType_GetsMultiplePackageTypes() { // Arrange var contents = @"<?xml version=""1.0""?> <package> <metadata> <packageTypes> <packageType name=""Foo"" version=""1.0"" /> <packageType name=""Bar"" version=""2.0"" /> </packageTypes> </metadata> </package>"; var reader = new TestNuspecCoreReader(contents); // Act var packageTypes = reader.GetPackageTypes(); // Assert Assert.Equal(2, packageTypes.Count()); var first = packageTypes.ElementAt(0); Assert.Equal("Foo", first.Name); Assert.Equal(new Version(1, 0), first.Version); var second = packageTypes.ElementAt(1); Assert.Equal("Bar", second.Name); Assert.Equal(new Version(2, 0), second.Version); }
public void GetPackageType_ReadsPackageTypeFromManifest(string contents, string expectedType, string expectedVersion) { // Arrange var reader = new TestNuspecCoreReader(contents); // Act var packageTypes = reader.GetPackageTypes(); // Assert Assert.Equal(1, packageTypes.Count()); var packageType = packageTypes.First(); Assert.Equal(expectedType, packageType.Name); Assert.Equal(expectedVersion, packageType.Version.ToString()); }
public void GetPackageType_ReturnsEmptyPackageTypeListIfNotSpecifiedInManfiest() { // Arrange var contents = @"<?xml version=""1.0""?> <package> <metadata/> </package>"; var reader = new TestNuspecCoreReader(contents); // Act var packageTypes = reader.GetPackageTypes(); // Assert Assert.Empty(packageTypes); }
public void GetPackageType_ThrowsIfPackageNameIsMissing() { // Arrange var contents = @"<?xml version=""1.0""?> <package> <metadata> <packageTypes> <packageType version=""1.0"">SomeFormat</packageType> </packageTypes> </metadata> </package>"; var reader = new TestNuspecCoreReader(contents); // Act and Assert var exception = Assert.Throws <PackagingException>(() => reader.GetPackageTypes()); Assert.Equal( "Nuspec file contains a package type that is missing the name attribute.", exception.Message); }
public void GetPackageType_ThrowsIfPackageTypeVersionCannotBeRead() { // Arrange var contents = @"<?xml version=""1.0""?> <package> <metadata> <packageTypes> <packageType name=""SomeFormat"" version=""3.5-alpha"" /> </packageTypes> </metadata> </package>"; var reader = new TestNuspecCoreReader(contents); // Act and Assert var exception = Assert.Throws <PackagingException>(() => reader.GetPackageTypes()); Assert.Equal( "Nuspec file contains a package type with an invalid package version '3.5-alpha'.", exception.Message); }