Exemple #1
0
            public void CalculatesTheSquaredDistanceBetweenTwoPointsCorrectly(NormalFloat nx1, NormalFloat ny1, NormalFloat nx2, NormalFloat ny2)
            {
                var x1 = nx1.Get;
                var x2 = nx2.Get;
                var y1 = ny1.Get;
                var y2 = ny2.Get;

                if (x1 > 10000000 || y1 > 10000000 || x2 > 10000000 || y2 > 10000000 ||
                    x1 < -10000000 || y1 < -10000000 || x2 < -10000000 || y2 < -10000000)
                {
                    return;
                }

                var a = new Point {
                    X = x1, Y = y1
                };
                var b = new Point {
                    X = x2, Y = y2
                };
                var dx = x1 - x2;
                var dy = y1 - y2;
                var correctDistance = System.Math.Sqrt(dx * dx + dy * dy);

                var distanceSq = DistanceSq(a, b);

                System.Math.Sqrt(distanceSq).Should().BeApproximately(correctDistance, 0.001);
            }
Exemple #2
0
            public void ReturnsEitherFloorOrCeilOfParameter(int seed, NormalFloat parameter)
            {
                var f = (float)parameter.Get;

                ResultOfCallingWith(seed, f)
                .Should().BeOneOf((int)Math.Floor(f), (int)Math.Ceiling(f));
            }
Exemple #3
0
            public void ShouldReturnValueInRange(int seed, NormalFloat bound1, NormalFloat bound2)
            {
                var(b1, b2) = (bound1.Get, bound2.Get);
                var(minimumValue, maximumValue) = b1 < b2
                    ? (b1, b2)
                    : (b2, b1);

                ResultOfCallingWith(seed, b1, b2)
                .Should().BeInRange(minimumValue, maximumValue);
            }
Exemple #4
0
            public void ShouldReturnValueInRange(int seed, NormalFloat bound)
            {
                var b = bound.Get;

                var(minimumValue, maximumValue) = b > 0
                    ? (0d, b)
                    : (b, 0d);

                ResultOfCallingWith(seed, b)
                .Should().BeInRange(minimumValue, maximumValue);
            }
Exemple #5
0
            public void ShouldReturnBoundIfBoundsAreEqual(int seed, NormalFloat bound)
            {
                var b = bound.Get;

                ResultOfCallingWith(seed, b, b).Should().Be(b);
            }
        public void Given_double_as_string_Number_should_parse_to_a_ConstantValueExpression_where_Value_property_holds_the_input(NormalFloat value)
        {
            // Arrange
            NumericValueExpression expected = new(value.Item.ToString(CultureInfo.InvariantCulture));
            string input = expected.EscapedParseableString;

            TokenList <FilterToken> tokens = _tokenizer.Tokenize(input);

            _outputHelper.WriteLine($"Tokens : ${StringifyTokens(tokens)}");

            // Act
            NumericValueExpression actual = FilterTokenParser.Number.Parse(tokens);

            // Assert
            AssertThatShould_parse(actual, expected);
        }