コード例 #1
0
        public void Arguments_AreNotAffectedAfterCreation()
        {
            // Arrange
            double formula(IReadOnlyList <double> args) => - 1;

            double[]             arguments = new double[] { 1.0, 2.0, 3.0 };
            CustomAreaCalculator sut       = new CustomAreaCalculator(formula, arguments);

            // Act
            arguments[0] = 0.0;

            // Assert
            sut.Arguments[0].Should().Be(1.0);
        }
コード例 #2
0
        public void Ctor_SetsProperties()
        {
            // Arrange
            Func <IReadOnlyList <double>, double> formula = (args) => - 1;

            double[] arguments = new double[] { 1.0, 2.0, 3.0 };

            // Act
            CustomAreaCalculator sut = new CustomAreaCalculator(formula, arguments);

            // Assert
            sut.Formula.Should().Be(formula);
            sut.Arguments.Should().BeEquivalentTo(arguments);
        }
コード例 #3
0
        public void CalculateArea_ReturnsExpectedValue()
        {
            // Arrange
            double formula(IReadOnlyList <double> args) => (args[0] + args[1]) * args[2];

            double[]             arguments = new double[] { 1.0, 2.0, 3.0 };
            CustomAreaCalculator sut       = new CustomAreaCalculator(formula, arguments);

            // Act
            double actual = sut.CalculateArea();

            // Assert
            double expected = 9.0;

            Tolerance.AreEqual(actual, expected).Should().BeTrue();
        }