Beispiel #1
0
        public void NullNugetPackages_AreSortedFirst()
        {
            var nugetPackage = new NugetPackage
            {
                Name    = "Package1",
                Version = "1.2.3",
            };

            // cast null as string to flex CompareTo(object obj) and CompareTo(NugetPackage other)
            Assert.Equal(1, nugetPackage.CompareTo((string)null));
        }
    public void VersionComparison(string smallerVersion, string greaterVersion)
    {
        var smallerPackage = new NugetPackage {
            Id = "TestPackage", Version = smallerVersion
        };
        var greaterPackage = new NugetPackage {
            Id = "TestPackage", Version = greaterVersion
        };

        Assert.IsTrue(smallerPackage.CompareTo(greaterPackage) < 0, "{0} was NOT smaller than {1}", smallerVersion, greaterVersion);
        Assert.IsTrue(greaterPackage.CompareTo(smallerPackage) > 0, "{0} was NOT greater than {1}", greaterVersion, smallerVersion);
    }
Beispiel #3
0
        public void NugetPackages_AreSortedByName()
        {
            var nugetPackage1 = new NugetPackage
            {
                Name    = "Package1",
                Version = "1.2.3",
            };
            var nugetPackage2 = new NugetPackage
            {
                Name    = "Package2",
                Version = "1.2.3",
            };

            Assert.Equal(-1, nugetPackage1.CompareTo(nugetPackage2));
        }