public void CalculateTotalRectangleAreas()
        {
            // Arrange
            const double expectedResult = 57;

            List <Rectangle> rectangles = new List <Rectangle>
            {
                new Rectangle()
                {
                    Length = 3,
                    Width  = 7
                },
                new Rectangle
                {
                    Length = 4,
                    Width  = 9
                }
            };

            _rectangleRepository.Setup(m => m.GetAll()).Returns(rectangles);

            RectangleCalculator calculator = new RectangleCalculator(_rectangleRepository.Object);

            // Act
            var result = calculator.GetSumCalculatedAreas();

            // Assert
            result.Should().BeApproximately(expectedResult, ExpectedPrecision);
        }
Beispiel #2
0
        public IsoscelesTriangleTestFigure(Pen pen)
        {
            points   = new List <Point>();
            this.pen = pen;

            painter    = new PolygonPainter();
            calculator = new RectangleCalculator();
            mover      = new PolygonMover();
            checker    = new PolygonChecker();
        }
Beispiel #3
0
        public IsoscelesTriangleTestFigure(Color color, int width)
        {
            points   = new List <Point>();
            this.pen = new Pen(color, width);

            painter    = new PolygonPainter();
            calculator = new RectangleCalculator();
            mover      = new PolygonMover();
            checker    = new PolygonChecker();
        }
Beispiel #4
0
        public IsoscelesTriangleTestFigure()
        {
            points = new List <Point>();

            painter         = new PolygonPainter();
            calculator      = new RectangleCalculator();
            mover           = new PolygonMover();
            checker         = new PolygonChecker();
            checkerInVertex = new PolygonChecker();
        }
        public double ComputeTotalArea()
        {
            double totalComputedArea = 0;

            totalComputedArea += new CircleCalculator(_repositories.Circles).GetSumCalculatedAreas();
            totalComputedArea += new RectangleCalculator(_repositories.Rectangles).GetSumCalculatedAreas();
            totalComputedArea += new SquareCalculator(_repositories.Squares).GetSumCalculatedAreas();
            totalComputedArea += new TriangleCalculator(_repositories.Triangles).GetSumCalculatedAreas();

            return(totalComputedArea);
        }
Beispiel #6
0
        public void Integral_Rectangle_XX_0_10_BadN()
        {
            //arrange
            double      a      = 0;
            double      b      = 10;
            int         n      = -1000000;
            ICalculator calcul = new RectangleCalculator();

            //act
            double actual = calcul.Calculate(a, b, n, x => x * x);
        }
Beispiel #7
0
 [ExpectedException(typeof(ArgumentException))] // 5 означает что выдаст исключение
 public void Intergrate_xx_negative_n()
 {
     // Arrange
     double a = 0;
     double b = a;
     long   n = -10;
     RectangleCalculator   rectangleCalculator = new RectangleCalculator();
     Func <double, double> f = x => x * x;
     // Act
     double actual = rectangleCalculator.Calculate(a, b, n, f);
 }
    private void Start()
    {
        List <Rectangle> rects = RectangleCalculator.GetCoverRects(mCanvas, mObjToHighlight);

        for (int i = 0; i < rects.Count; i++)
        {
            Rectangle rect = rects[i];
            var       obj  = Instantiate <GameObject>(mImgObj);
            obj.transform.SetParent(mParent.transform, false);
            obj.transform.localScale = Vector3.one;
            RectTransform rTrans = obj.GetComponent <RectTransform>();
            rTrans.localPosition = GetPositionFromRectangle(rect);
            rTrans.sizeDelta     = GetSizeOfARecangle(rect);
        }
    }
Beispiel #9
0
        public void Integral_Rectangle_0_0_10_Correct()
        {
            //arrange
            double      expected = 0;
            double      a        = 0;
            double      b        = 10;
            int         n        = 10000;
            ICalculator calcul   = new RectangleCalculator();

            //act
            double actual = calcul.Calculate(a, b, n, x => 0);

            //assert
            Assert.AreEqual(expected, actual, 0.001);
        }
Beispiel #10
0
        public void Integral_Rectangle_XX_0_10_Correct()
        {
            //arrange подготовить
            double      expected = 333.333;
            double      a        = 0;
            double      b        = 10;
            int         n        = 10000;
            ICalculator calcul   = new RectangleCalculator();

            //act действие
            double actual = calcul.Calculate(a, b, n, x => x * x);

            //assert
            Assert.AreEqual(expected, actual, 0.001);
        }
Beispiel #11
0
        public void Intergrate_xx_Gives_0_For_Rectangle() // 3 проверка 0 для прямоугольников
        {
            //arrange
            double expected = 0;
            double a        = 0;
            double b        = a;
            long   n        = 100000;
            RectangleCalculator   rectangleCalculator = new RectangleCalculator();
            Func <double, double> f = x => x * x;
            //act
            double actual = rectangleCalculator.Calculate(a, b, n, f);

            //assert
            Assert.AreEqual(expected, actual, 0.0001);
        }
Beispiel #12
0
        public void RectangleCalculator_Right()
        {
            //arrange
            double expected = 174591.027;
            int    a        = 1;
            int    b        = 100;
            int    n        = 100000;
            RectangleCalculator   rectangleCalculator = new RectangleCalculator();
            Func <double, double> f = x => 35 * x - Math.Log(10 * x) + 2;

            //act
            double actual = rectangleCalculator.Calculate(a, b, n, f);

            //accert
            Assert.AreEqual(expected, actual, 0.001);
        }
Beispiel #13
0
        public void Correct_Rectangle_Method_2()
        {
            //arrange
            double expected = 54197.59134;
            double a        = 1;
            double b        = 100;
            long   n        = 10000;
            RectangleCalculator   rectangleCalculator = new RectangleCalculator();
            Func <double, double> f = x => 11 * x - Math.Log(11 * x) - 2;

            //act
            double actual = rectangleCalculator.Calculate(a, b, n, f);

            //assert

            Assert.AreEqual(expected, actual, 0.0001);
        }
Beispiel #14
0
        public void Correct_Rectangle_Method_1()
        {
            //arrange
            double expected = 36458.33333;
            double a        = 25;
            double b        = 50;
            long   n        = 10000;
            RectangleCalculator   rectangleCalculator = new RectangleCalculator();
            Func <double, double> f = x => x * x;

            //act
            double actual = rectangleCalculator.Calculate(a, b, n, f);

            //assert

            Assert.AreEqual(expected, actual, 0.0001);
        }
        public void Intergrate_xx_negative_n()
        {
            //arrange
            double expected = 0;
            double a        = 0;
            double b        = 100;

            long n = -10;
            RectangleCalculator   rectangleCalculator = new RectangleCalculator();
            Func <double, double> f = x => x * x;

            //act
            double actual = rectangleCalculator.Calculate(a, b, n, f);

            //assert
            Assert.AreEqual(expected, actual, 0.0001);
        }
        public void Intergrate_xx_Gives_Correct_Result()
        {
            //arrange
            double expected = 333_333.3333;
            double a        = 0;
            double b        = 100;
            long   n        = 100000;
            RectangleCalculator   rectangleCalculator = new RectangleCalculator();
            Func <double, double> f = x => x * x;

            //act
            double actual = rectangleCalculator.Calculate(a, b, n, f);

            //assert

            Assert.AreEqual(expected, actual, 0.0001);
        }
Beispiel #17
0
        public void Error_if_a_and_b_below_zero()
        {
            double expected         = 174591.027;
            int    a                = -1;
            int    b                = -100;
            int    n                = 100;
            Func <double, double> f = x => 35 * x - Math.Log(10 * x) + 2;

            RectangleCalculator RectangleCalculator = new RectangleCalculator();
            TrapCalculator      TrapCalculator      = new TrapCalculator();
            SimpsonCalculator   SimpsonCalculator   = new SimpsonCalculator();

            //act
            double actual1 = RectangleCalculator.Calculate(a, b, n, f);
            double actual2 = TrapCalculator.Calculate(a, b, n, f);
            double actual3 = SimpsonCalculator.Calculate(a, b, n, f);
        }