Determines whether the current version range is satisfied by all specified SemanticVersion instances.
public void BasicComparison() { VersionRange vr0 = new VersionRange("1.2.3"), vr1 = new VersionRange("=1.2.3"), vr2 = new VersionRange(">1.2.3"), vr3 = new VersionRange("<1.2.3"), vr4 = new VersionRange(">=1.2.3"), vr5 = new VersionRange("<=1.2.3") ; SemanticVersion sv0 = new SemanticVersion(1, 2, 3), sv1 = new SemanticVersion(1, 2, 2), sv2 = new SemanticVersion(1, 2, 3, new[] { "alpha" }), sv3 = new SemanticVersion(1, 2, 4), sv4 = new SemanticVersion(1, 2, 4, new[] { "alpha" }) ; // Testing satisfaction Assert.IsTrue(vr0.SatisfiedBy(sv0), "Incorrect rejection (0)."); Assert.IsTrue(vr1.SatisfiedBy(sv0), "Incorrect rejection (1)."); Assert.IsTrue(vr2.SatisfiedBy(sv3), "Incorrect rejection (2)."); Assert.IsTrue(vr4.SatisfiedBy(sv0), "Incorrect rejection (4)."); Assert.IsTrue(vr4.SatisfiedBy(sv3), "Incorrect rejection (5)."); Assert.IsTrue(vr5.SatisfiedBy(sv0), "Incorrect rejection (6)."); Assert.IsTrue(vr5.SatisfiedBy(sv1), "Incorrect rejection (7)."); Assert.IsTrue(vr2.SatisfiedBy(sv4), "Incorrect rejection (8)."); Assert.IsTrue(vr4.SatisfiedBy(sv4), "Incorrect rejection (9)."); // And testing dissatisfaction Assert.IsFalse(vr0.SatisfiedBy(sv1), "Incorrect acceptance (0)."); Assert.IsFalse(vr0.SatisfiedBy(sv2), "Incorrect acceptance (1)."); Assert.IsFalse(vr0.SatisfiedBy(sv3), "Incorrect acceptance (2)."); Assert.IsFalse(vr1.SatisfiedBy(sv1), "Incorrect acceptance (3)."); Assert.IsFalse(vr1.SatisfiedBy(sv2), "Incorrect acceptance (4)."); Assert.IsFalse(vr1.SatisfiedBy(sv3), "Incorrect acceptance (5)."); Assert.IsFalse(vr3.SatisfiedBy(sv2), "Incorrect acceptance (6)."); }
public void MultipleComparators() { // This test is taken from the README of the 'node-semver' // repository, because what better source than the horse's // mouth? // // We only have a single test because we have another test // for the individual comparators, we just want to make sure // that multiple comparators are treated as expected. VersionRange vr0 = new VersionRange(">=1.2.7 <1.3.0") ; SemanticVersion sv0 = new SemanticVersion(1, 2, 7), // These three are sv1 = new SemanticVersion(1, 2, 8), // matches. sv2 = new SemanticVersion(1, 2, 99), sv3 = new SemanticVersion(1, 2, 6), // And these are sv4 = new SemanticVersion(1, 3, 0), // mismatches. sv5 = new SemanticVersion(1, 1, 0) ; Assert.IsTrue(vr0.SatisfiedBy(sv0), "Incorrect rejection (0)."); Assert.IsTrue(vr0.SatisfiedBy(sv1), "Incorrect rejection (1)."); Assert.IsTrue(vr0.SatisfiedBy(sv2), "Incorrect rejection (2)."); Assert.IsFalse(vr0.SatisfiedBy(sv3), "Incorrect acceptance (0)."); Assert.IsFalse(vr0.SatisfiedBy(sv4), "Incorrect acceptance (1)."); Assert.IsFalse(vr0.SatisfiedBy(sv5), "Incorrect acceptance (2)."); }
public void MultipleComparatorSets() { // Like in the [MultipleComparators] test, this test is straight // from the 'node-semver' README, and there's only a single test // because individual comparators and multiple comparators are // already tested. VersionRange vr0 = new VersionRange("1.2.7 || >=1.2.9 <2.0.0"); SemanticVersion sv0 = new SemanticVersion(1, 2, 7), // These match. sv1 = new SemanticVersion(1, 2, 9), sv2 = new SemanticVersion(1, 4, 6), sv3 = new SemanticVersion(1, 2, 8), // These don't. sv4 = new SemanticVersion(2, 0, 0) ; Assert.IsTrue(vr0.SatisfiedBy(sv0), "Incorrect rejection (0)."); Assert.IsTrue(vr0.SatisfiedBy(sv1), "Incorrect rejection (1)."); Assert.IsTrue(vr0.SatisfiedBy(sv2), "Incorrect rejection (2)."); Assert.IsFalse(vr0.SatisfiedBy(sv3), "Incorrect acceptance (0)."); Assert.IsFalse(vr0.SatisfiedBy(sv4), "Incorrect acceptance (1)."); }