public void CompareTo_WhenCommitTimeStampsAreEqual_ReturnsZero() { var entry0 = new CatalogIndexEntry( new Uri("https://nuget.test/a"), CatalogConstants.NuGetPackageDetails, _commitId, _commitTimeStamp, _packageIdentity); var entry1 = new CatalogIndexEntry( new Uri("https://nuget.test/b"), CatalogConstants.NuGetPackageDelete, Guid.NewGuid().ToString(), _commitTimeStamp, new PackageIdentity(id: "b", version: new NuGetVersion("4.5.6"))); Assert.Equal(0, entry0.CompareTo(entry0)); Assert.Equal(0, entry0.CompareTo(entry1)); Assert.Equal(0, entry1.CompareTo(entry0)); }
public void CompareTo_WhenOtherIsNull_Throws() { var entry = new CatalogIndexEntry( _uri, CatalogConstants.NuGetPackageDetails, _commitId, _commitTimeStamp, _packageIdentity); var exception = Assert.Throws <ArgumentNullException>(() => entry.CompareTo(other: null)); Assert.Equal("other", exception.ParamName); }
public void CompareTo_WhenCommitTimeStampsAreNotEqual_ReturnsNonZero() { var now = DateTime.UtcNow; var olderEntry = new CatalogIndexEntry( _uri, CatalogConstants.NuGetPackageDetails, _commitId, now.AddHours(-1), _packageIdentity); var newerEntry = new CatalogIndexEntry( _uri, CatalogConstants.NuGetPackageDetails, _commitId, now, _packageIdentity); Assert.Equal(-1, olderEntry.CompareTo(newerEntry)); Assert.Equal(1, newerEntry.CompareTo(olderEntry)); }