本文整理汇总了C#中SemanticVersion.Equals方法的典型用法代码示例。如果您正苦于以下问题:C# SemanticVersion.Equals方法的具体用法?C# SemanticVersion.Equals怎么用?C# SemanticVersion.Equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SemanticVersion
的用法示例。
在下文中一共展示了SemanticVersion.Equals方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Equality
public void Equality()
{
var sv12a = new SemanticVersion(new Version(1, 2), null);
var sv12b = new SemanticVersion(new Version(1, 2), null);
Assert.Equal(sv12a, sv12b);
var sv13 = new SemanticVersion(new Version(1, 3), null);
Assert.NotEqual(sv12a, sv13);
var sv12Pre = new SemanticVersion(new Version(1, 2), "-pre");
var sv12Beta = new SemanticVersion(new Version(1, 2), "-beta");
Assert.NotEqual(sv12a, sv12Pre);
Assert.NotEqual(sv12Pre, sv12Beta);
Assert.Equal(sv12Pre, sv12Pre);
Assert.False(sv12a.Equals(null));
}
示例2: Equality
public void Equality()
{
var sv12a = new SemanticVersion(new Version(1, 2), null);
var sv12b = new SemanticVersion(new Version(1, 2), null);
Assert.Equal(sv12a, sv12b);
var sv13 = new SemanticVersion(new Version(1, 3), null);
Assert.NotEqual(sv12a, sv13);
var sv12Pre = new SemanticVersion(new Version(1, 2), "-pre");
var sv12Beta = new SemanticVersion(new Version(1, 2), "-beta");
Assert.NotEqual(sv12a, sv12Pre);
Assert.NotEqual(sv12Pre, sv12Beta);
Assert.Equal(sv12Pre, sv12Pre);
var sv12BuildInfo = new SemanticVersion(new Version(1, 2), buildMetadata: "+buildInfo");
var sv12OtherBuildInfo = new SemanticVersion(new Version(1, 2), buildMetadata: "+otherBuildInfo");
Assert.NotEqual(sv12BuildInfo, sv12OtherBuildInfo);
Assert.Equal(sv12BuildInfo, sv12BuildInfo);
Assert.False(sv12a.Equals(null));
}
示例3: SemVerEqualsOperatorWorks
public void SemVerEqualsOperatorWorks(string versionA, string versionB)
{
// Arrange
var itemA = new SemanticVersion(versionA);
var itemB = new SemanticVersion(versionB);
object objectB = itemB;
// Act and Assert
Assert.True(itemA == itemB);
Assert.True(itemA.Equals(itemB));
Assert.True(itemA.Equals(objectB));
Assert.True(itemA <= itemB);
Assert.True(itemB == itemA);
Assert.True(itemB >= itemA);
}
示例4: EqualsReturnsFalseIfComparingANonSemVerType
public void EqualsReturnsFalseIfComparingANonSemVerType(object other)
{
// Arrange
var semVer = new SemanticVersion("1.0.0");
// Act and Assert
Assert.False(semVer.Equals(other));
}
示例5: SemVerLessThanAndGreaterThanOperatorsWorks
public void SemVerLessThanAndGreaterThanOperatorsWorks(string versionA, string versionB)
{
// Arrange
var itemA = new SemanticVersion(versionA);
var itemB = new SemanticVersion(versionB);
object objectB = itemB;
// Act and Assert
Assert.True(itemA < itemB);
Assert.True(itemA <= itemB);
Assert.True(itemB > itemA);
Assert.True(itemB >= itemA);
Assert.False(itemA.Equals(itemB));
Assert.False(itemA.Equals(objectB));
}
示例6: EqualsWhereNot
public void EqualsWhereNot()
{
// Setup
var version1 = new SemanticVersion("1.0.0-alpha");
var version2 = new SemanticVersion(4, 15, 26, "beta6");
// Execute
var result = version1.Equals(version2);
// Assert
Assert.IsFalse(result);
}
示例7: Equals
public void Equals()
{
// Setup
var version1 = new SemanticVersion("4.15.26-beta6");
var version2 = new SemanticVersion(4, 15, 26, "beta6");
// Execute
var result = version1.Equals(version2);
// Assert
Assert.IsTrue(result);
}
示例8: FindPackage
IPackage FindPackage(int attempt, string packageId, string packageVersion, string feed, out NuGet.PackageDownloader downloader)
{
Log.VerboseFormat("Finding package (attempt {0} of {1})", attempt, NumberOfTimesToAttemptToDownloadPackage);
var remoteRepository = packageRepositoryFactory.CreateRepository(feed);
var dspr = remoteRepository as DataServicePackageRepository;
downloader = dspr != null ? dspr.PackageDownloader : null;
var requiredVersion = new SemanticVersion(packageVersion);
var package = remoteRepository.FindPackage(packageId, requiredVersion, true, true);
if (package == null)
throw new Exception(string.Format("Could not find package {0} {1} in feed: '{2}'", packageId, packageVersion, feed));
if (!requiredVersion.Equals(package.Version))
{
var message = string.Format("The package version '{0}' returned from the package repository doesn't match the requested package version '{1}'.", package.Version, requiredVersion);
throw new Exception(message);
}
return package;
}
示例9: SemVerArentEqualToNull
public void SemVerArentEqualToNull(SemanticVersion semVer)
{
const bool expected = false;
var actual = semVer.Equals(null);
Assert.Equal(expected, actual);
}
示例10: SemVerEqualsItself
public void SemVerEqualsItself(SemanticVersion semVer)
{
const bool expected = true;
var actual = semVer.Equals(semVer);
Assert.Equal(expected, actual);
}
示例11: SemVerArentEqualToStringEmpty
public void SemVerArentEqualToStringEmpty(SemanticVersion semVer)
{
const bool expected = false;
var actual = semVer.Equals(string.Empty);
Assert.Equal(expected, actual);
}
示例12: OverridedEqualsTest
public void OverridedEqualsTest()
{
SemanticVersion o = null;
SemanticVersion v = new SemanticVersion(4, 2, 1);
Assert.False(v.Equals(o));
Assert.False(v.Equals(new PreRelease(PreReleaseStage.ALPHA)));
o = v;
Assert.True(v.Equals(o));
o = new SemanticVersion(4, 2, 1);
Assert.True(v.Equals(o));
}