Ejemplo n.º 1
0
        public void Exclude_MultipleValues_WithCaseSensitiveComparer(string[] restrict, string[] exclude)
        {
            // arrange
            ConstraintSet <string> set = this.CreateAndAssertSet <string>();

            // act
            bool added   = set.Exclude(restrict);
            bool reAdded = set.Exclude(restrict);

            // assert
            this.AssertBounds(set, Array.Empty <string>(), exclude);
            added.Should().BeTrue();
            reAdded.Should().BeFalse();
        }
Ejemplo n.º 2
0
        public void Exclude_MultipleValues(params int[] values)
        {
            // arrange
            ConstraintSet <int> set = this.CreateAndAssertSet <int>();

            // act
            bool added   = set.Exclude(values);
            bool reAdded = set.Exclude(values);

            // assert
            this.AssertBounds(set, Array.Empty <int>(), values);
            added.Should().BeTrue();
            reAdded.Should().BeFalse();
        }
Ejemplo n.º 3
0
        public void Exclude_MultipleValues_WithCaseInsensitiveComparer(string[] input, string[] expected)
        {
            // arrange
            ConstraintSet <string> set = this.CreateAndAssertSet(StringComparer.OrdinalIgnoreCase);

            // act
            bool added   = set.Exclude(input);
            bool reAdded = set.Exclude(input);

            // assert
            this.AssertBounds(set, Array.Empty <string>(), expected);
            added.Should().BeTrue();
            reAdded.Should().BeFalse();
        }
Ejemplo n.º 4
0
        public void Exclude_SingleValue <T>(T value)
        {
            // arrange
            ConstraintSet <T> set = this.CreateAndAssertSet <T>();

            // act
            bool added   = set.Exclude(value);
            bool reAdded = set.Exclude(value);

            // assert
            this.AssertBounds(set, Array.Empty <T>(), new[] { value });
            added.Should().BeTrue();
            reAdded.Should().BeFalse();
        }
Ejemplo n.º 5
0
        public void Exclude_SingleValue_WithCaseSensitiveComparer()
        {
            // arrange
            const string           value = "boop";
            ConstraintSet <string> set   = this.CreateAndAssertSet <string>();

            // act
            bool added   = set.Exclude(value);
            bool reAdded = set.Exclude(value.ToUpper());

            // assert
            this.AssertBounds(set, Array.Empty <string>(), new[] { value, value.ToUpper() });
            added.Should().BeTrue();
            reAdded.Should().BeTrue();
        }
        public void Exclude_SingleValue_WithCaseInsensitiveComparer()
        {
            // arrange
            const string           value = "boop";
            ConstraintSet <string> set   = this.CreateAndAssertSet(StringComparer.OrdinalIgnoreCase);

            // act
            bool added   = set.Exclude(value);
            bool reAdded = set.Exclude(value.ToUpper());

            // assert
            this.AssertBounds(set, new string[0], new[] { value });
            added.Should().BeTrue();
            reAdded.Should().BeFalse();
        }
Ejemplo n.º 7
0
        public void Allows_WithCaseSensitiveComparer(string[] restrict, string[] exclude, string?[] test, bool expectedResult)
        {
            // arrange
            ConstraintSet <string?> set = this.CreateAndAssertSet <string?>();

            set.AddBound(restrict);
            set.Exclude(exclude);
            this.AssertBounds(set, restrict, exclude);

            // act/assert
            foreach (string?value in test)
            {
                set.Allows(value).Should().Be(expectedResult, $"expected '{value}' to {(expectedResult ? "be allowed" : "be excluded")}");
            }
        }
Ejemplo n.º 8
0
        public void Allows_WithFloats(float[] restrict, float[] exclude, float[] test, bool expectedResult)
        {
            // arrange
            ConstraintSet <float> set = this.CreateAndAssertSet <float>();

            set.AddBound(restrict);
            set.Exclude(exclude);
            this.AssertBounds(set, restrict, exclude);

            // act/assert
            foreach (float value in test)
            {
                set.Allows(value).Should().Be(expectedResult, $"expected '{value}' to {(expectedResult ? "be allowed" : "be excluded")}");
            }
        }
Ejemplo n.º 9
0
        public void Intersects_OneInfinite_NonIntersection()
        {
            // arrange
            ConstraintSet <string> left  = this.CreateAndAssertSet(StringComparer.OrdinalIgnoreCase);
            ConstraintSet <string> right = this.CreateAndAssertSet(StringComparer.OrdinalIgnoreCase);

            left.Exclude(new[] { "A", "B", "C" });
            right.AddBound(new[] { "A", "B", "C" });

            // act
            bool leftIntersects  = left.Intersects(right);
            bool rightIntersects = right.Intersects(left);

            // assert
            leftIntersects.Should().BeFalse();
            rightIntersects.Should().BeFalse();
        }
Ejemplo n.º 10
0
        public void Intersects_BothInfinite_Intersection()
        {
            // arrange
            ConstraintSet <string> left  = this.CreateAndAssertSet(StringComparer.OrdinalIgnoreCase);
            ConstraintSet <string> right = this.CreateAndAssertSet(StringComparer.OrdinalIgnoreCase);

            left.Exclude("C");
            right.Exclude("D");

            // act
            bool leftIntersects  = left.Intersects(right);
            bool rightIntersects = right.Intersects(left);

            // assert
            leftIntersects.Should().BeTrue();
            rightIntersects.Should().BeTrue();
        }
Ejemplo n.º 11
0
        public void Allows_WithCaseInsensitiveComparer(string[] restrict, string[] exclude, string[] test, bool expectedResult)
        {
            // arrange
            ConstraintSet <string> set = this.CreateAndAssertSet(StringComparer.OrdinalIgnoreCase);

            set.AddBound(restrict);
            set.Exclude(exclude);
            this.AssertBounds(
                set,
                new HashSet <string>(restrict, StringComparer.OrdinalIgnoreCase).ToArray(),
                new HashSet <string>(exclude, StringComparer.OrdinalIgnoreCase).ToArray()
                );

            // act/assert
            foreach (string value in test)
            {
                set.Allows(value).Should().Be(expectedResult, $"expected '{value}' to {(expectedResult ? "be allowed" : "be excluded")}");
            }
        }
Ejemplo n.º 12
0
        public void Intersects_Bounded_Intersection()
        {
            // arrange
            ConstraintSet <string> left  = this.CreateAndAssertSet(StringComparer.InvariantCultureIgnoreCase);
            ConstraintSet <string> right = this.CreateAndAssertSet(StringComparer.InvariantCultureIgnoreCase);

            left.AddBound(new[] { "A", "B", "C", "D" });
            right.AddBound(new[] { "C", "D" });
            left.Exclude("C");
            right.Exclude("C");

            // act
            bool leftIntersects  = left.Intersects(right);
            bool rightIntersects = right.Intersects(left);

            // assert
            leftIntersects.Should().BeTrue();
            rightIntersects.Should().BeTrue();
        }