Esempio n. 1
0
        public void TestThrowOnAlmostEqualVectorsWithSizeDifference()
        {
            UniRectangle testRectangle = new UniRectangle(
                new UniVector(
                    new UniScalar(minusOneFloat, plusOneFloat),
                    new UniScalar(plusOneFloat, minusOneFloat)
                    ),
                new UniVector(
                    new UniScalar(plusTwoFloat, minusTwoFloat),
                    new UniScalar(minusTwoFloat, plusTwoFloat)
                    )
                );
            UniRectangle exactRectangle = new UniRectangle(
                new UniVector(
                    new UniScalar(exactFloat, exactFloat),
                    new UniScalar(exactFloat, exactFloat)
                    ),
                new UniVector(
                    new UniScalar(exactFloat, exactFloat),
                    new UniScalar(exactFloat, exactFloat)
                    )
                );

            Assert.Throws <AssertionException>(
                delegate() { UniAssertHelper.AreAlmostEqual(exactRectangle, testRectangle, 1); }
                );
        }
Esempio n. 2
0
        public void TestAlmostEqualRectangles()
        {
            UniRectangle testRectangle = new UniRectangle(
                new UniVector(
                    new UniScalar(minusOneFloat, plusOneFloat),
                    new UniScalar(plusOneFloat, minusOneFloat)
                    ),
                new UniVector(
                    new UniScalar(plusOneFloat, minusOneFloat),
                    new UniScalar(minusOneFloat, plusOneFloat)
                    )
                );
            UniRectangle exactRectangle = new UniRectangle(
                new UniVector(
                    new UniScalar(exactFloat, exactFloat),
                    new UniScalar(exactFloat, exactFloat)
                    ),
                new UniVector(
                    new UniScalar(exactFloat, exactFloat),
                    new UniScalar(exactFloat, exactFloat)
                    )
                );

            UniAssertHelper.AreAlmostEqual(exactRectangle, testRectangle, 1);
        }
Esempio n. 3
0
        public void TestAdditionOperator()
        {
            UniScalar testScalar  = new UniScalar(1.2f, 3.4f);
            UniScalar addedScalar = new UniScalar(5.6f, 7.8f);

            UniAssertHelper.AreAlmostEqual(
                new UniScalar(6.8f, 11.2f), testScalar + addedScalar, 4
                );
        }
Esempio n. 4
0
        public void TestDivisionOperator()
        {
            UniScalar testScalar    = new UniScalar(1.2f, 3.4f);
            UniScalar divisorScalar = new UniScalar(2.5f, 5.0f);

            UniAssertHelper.AreAlmostEqual(
                new UniScalar(0.48f, 0.68f), testScalar / divisorScalar, 4
                );
        }
Esempio n. 5
0
        public void TestMultiplicationOperator()
        {
            UniScalar testScalar   = new UniScalar(1.2f, 3.4f);
            UniScalar factorScalar = new UniScalar(5.6f, 7.8f);

            UniAssertHelper.AreAlmostEqual(
                new UniScalar(6.72f, 26.52f), testScalar * factorScalar, 4
                );
        }
Esempio n. 6
0
        public void TestSubtractionOperator()
        {
            UniScalar testScalar       = new UniScalar(1.2f, 3.4f);
            UniScalar subtractedScalar = new UniScalar(5.6f, 7.8f);

            UniAssertHelper.AreAlmostEqual(
                new UniScalar(-4.4f, -4.4f), testScalar - subtractedScalar, 4
                );
        }
Esempio n. 7
0
        public void TestThrowOnAlmostEqualScalarsWithTooLowOffset()
        {
            UniScalar testScalar = new UniScalar(exactFloat, minusTwoFloat);

            Assert.Throws <AssertionException>(
                delegate() {
                UniAssertHelper.AreAlmostEqual(
                    new UniScalar(exactFloat, exactFloat), testScalar, 1
                    );
            }
                );
        }
Esempio n. 8
0
        public void TestAlmostEqualVectors()
        {
            UniVector testVector = new UniVector(
                new UniScalar(minusOneFloat, plusOneFloat),
                new UniScalar(plusOneFloat, minusOneFloat)
                );
            UniVector exactVector = new UniVector(
                new UniScalar(exactFloat, exactFloat),
                new UniScalar(exactFloat, exactFloat)
                );

            UniAssertHelper.AreAlmostEqual(testVector, exactVector, 1);
        }
        public void TestMaxProperty()
        {
            UniVector    minVector     = new UniVector(firstTestScalar, secondTestScalar);
            UniVector    maxVector     = new UniVector(thirdTestScalar, fourthTestScalar);
            UniRectangle testRectangle = new UniRectangle(UniVector.Zero, minVector);

            testRectangle.Max = maxVector;

            Assert.AreEqual(UniVector.Zero, testRectangle.Min);
            Assert.AreEqual(UniVector.Zero, testRectangle.Location);

            UniAssertHelper.AreAlmostEqual(maxVector, testRectangle.Max, 4);
            UniAssertHelper.AreAlmostEqual(maxVector, testRectangle.Size, 4);
        }
        public void TestMinProperty()
        {
            UniVector    minVector     = new UniVector(firstTestScalar, secondTestScalar);
            UniVector    maxVector     = new UniVector(thirdTestScalar, fourthTestScalar);
            UniRectangle testRectangle = new UniRectangle(UniVector.Zero, maxVector);

            // This doesn't move the rectangle, it resizes it!
            testRectangle.Min = minVector;

            Assert.AreEqual(minVector, testRectangle.Min);
            Assert.AreEqual(minVector, testRectangle.Location);

            UniAssertHelper.AreAlmostEqual(maxVector, testRectangle.Max, 4);
            UniAssertHelper.AreAlmostEqual(maxVector - minVector, testRectangle.Size, 4);
        }
Esempio n. 11
0
        public void TestThrowOnAlmostEqualVectorsWithYDifference()
        {
            UniVector testVector = new UniVector(
                new UniScalar(minusOneFloat, plusOneFloat),
                new UniScalar(plusTwoFloat, minusTwoFloat)
                );
            UniVector exactVector = new UniVector(
                new UniScalar(exactFloat, exactFloat),
                new UniScalar(exactFloat, exactFloat)
                );

            Assert.Throws <AssertionException>(
                delegate() { UniAssertHelper.AreAlmostEqual(exactVector, testVector, 1); }
                );
        }
Esempio n. 12
0
        public void TestAlmostEqualScalars()
        {
            UniScalar testScalar = new UniScalar(minusOneFloat, plusOneFloat);

            UniAssertHelper.AreAlmostEqual(new UniScalar(exactFloat, exactFloat), testScalar, 1);
        }