Beispiel #1
0
        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);
            }
        }
Beispiel #2
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();
            }
        }