public void ParseRangeString_should_parse_valid_ranges() { // Arrange var rules = new Dictionary <string, Tuple <SemanticVersion, SemanticVersion> > { { "1.0", new Tuple <SemanticVersion, SemanticVersion>( SemanticVersionRange.Inclusive(new SemanticVersion(1, 0, 0)), SemanticVersionRange.Inclusive(SemanticVersion.MaxValue)) }, { "(,1.0]", new Tuple <SemanticVersion, SemanticVersion>( SemanticVersionRange.Exclusive(SemanticVersion.Unspecified), SemanticVersionRange.Inclusive(new SemanticVersion(1, 0, 0))) }, { "(,1.0)", new Tuple <SemanticVersion, SemanticVersion>( SemanticVersionRange.Exclusive(SemanticVersion.Unspecified), SemanticVersionRange.Exclusive(new SemanticVersion(1, 0, 0))) }, { "[1.0]", new Tuple <SemanticVersion, SemanticVersion>( SemanticVersionRange.Inclusive(new SemanticVersion(1, 0, 0)), SemanticVersionRange.Inclusive(new SemanticVersion(1, 0, 0))) }, { "(1.0,)", new Tuple <SemanticVersion, SemanticVersion>( SemanticVersionRange.Exclusive(new SemanticVersion(1, 0, 0)), SemanticVersionRange.Exclusive(SemanticVersion.MaxValue)) }, { "(1.0,2.0)", new Tuple <SemanticVersion, SemanticVersion>( SemanticVersionRange.Exclusive(new SemanticVersion(1, 0, 0)), SemanticVersionRange.Exclusive(new SemanticVersion(2, 0, 0))) }, { "[1.0,2.0]", new Tuple <SemanticVersion, SemanticVersion>( SemanticVersionRange.Inclusive(new SemanticVersion(1, 0, 0)), SemanticVersionRange.Inclusive(new SemanticVersion(2, 0, 0))) } }; foreach (var rule in rules) { // Act var actual = SemanticVersionRange.ParseRangeString(rule.Key); // Assert actual.Item1.Should().Be(rule.Value.Item1); actual.Item2.Should().Be(rule.Value.Item2); } }
public void ExclusiveVersion_CompareTo_should_return_positive_value() { // Arrange var version = SemanticVersionRange.Exclusive(new SemanticVersion(1, 0, 0)); // Act // Assert version.CompareTo(new SemanticVersion(0, 9, 0)).Should().BeGreaterThan(0); }
public void Compare_should_return_true_for_values_in_range() { // Arrange var rules = new List <Tuple <SemanticVersionRange, SemanticVersion> > { new Tuple <SemanticVersionRange, SemanticVersion>( new SemanticVersionRange(SemanticVersionRange.Inclusive(new SemanticVersion(1, 0, 0)), SemanticVersionRange.Inclusive(SemanticVersion.MaxValue)), new SemanticVersion(1, 0, 0) ), new Tuple <SemanticVersionRange, SemanticVersion>( new SemanticVersionRange(SemanticVersionRange.Exclusive(SemanticVersion.Unspecified), SemanticVersionRange.Inclusive(new SemanticVersion(1, 0, 0))), new SemanticVersion(1, 0, 0) ), new Tuple <SemanticVersionRange, SemanticVersion>( new SemanticVersionRange(SemanticVersionRange.Exclusive(SemanticVersion.Unspecified), SemanticVersionRange.Exclusive(new SemanticVersion(1, 0, 0))), new SemanticVersion(0, 9, 0) ), new Tuple <SemanticVersionRange, SemanticVersion>( new SemanticVersionRange(SemanticVersionRange.Inclusive(new SemanticVersion(1, 0, 0)), SemanticVersionRange.Inclusive(new SemanticVersion(1, 0, 0))), new SemanticVersion(1, 0, 0) ), new Tuple <SemanticVersionRange, SemanticVersion>( new SemanticVersionRange(SemanticVersionRange.Exclusive(new SemanticVersion(1, 0, 0)), SemanticVersionRange.Inclusive(SemanticVersion.MaxValue)), new SemanticVersion(1, 1, 0) ), new Tuple <SemanticVersionRange, SemanticVersion>( new SemanticVersionRange(SemanticVersionRange.Exclusive(new SemanticVersion(1, 0, 0)), SemanticVersionRange.Exclusive(new SemanticVersion(2, 0, 0))), new SemanticVersion(1, 5, 0) ), new Tuple <SemanticVersionRange, SemanticVersion>( new SemanticVersionRange(SemanticVersionRange.Inclusive(new SemanticVersion(1, 0, 0)), SemanticVersionRange.Inclusive(new SemanticVersion(2, 0, 0))), new SemanticVersion(1, 0, 0) ) }; foreach (var rule in rules) { // Act // Assert rule.Item1.Contains(rule.Item2).Should().BeTrue(); } }
public void ExclusiveVersion_CompareTo_should_return_negative_values() { // Arrange var version = (SemanticVersionRange.ExclusiveVersion)SemanticVersionRange.Exclusive(new SemanticVersion(1, 0, 0)); version.IsLowerBound = false; var a = (SemanticVersionRange.ExclusiveVersion)SemanticVersionRange.Exclusive(new SemanticVersion(1, 0, 0)); a.IsLowerBound = false; var b = (SemanticVersionRange.ExclusiveVersion)SemanticVersionRange.Exclusive(new SemanticVersion(1, 0, 1)); b.IsLowerBound = false; // Act // Assert version.CompareTo(a).Should().BeLessThan(0); version.CompareTo(b).Should().BeLessThan(0); }