public void Constructor_SetsLengthCounterClockwise_WhenCalled()
 {
     NUnitHelper.AssertIsEquivalent(157.07963267948966,
                                    m_Sut.LengthCounterClockwise,
                                    Constants.EpsilonDistance,
                                    "LengthCounterClockwise");
 }
 public void Constructor_SetsLengthClockwise_WhenCalled()
 {
     NUnitHelper.AssertIsEquivalent(471.23889803846896,
                                    m_Sut.LengthClockwise,
                                    Constants.EpsilonDistance,
                                    "LengthClockwise");
 }
 public void Constructor_SetsLength_WhenCalled()
 {
     // Arrange
     // Act
     // Assert
     NUnitHelper.AssertIsEquivalent(12.34,
                                    m_Sut.Length);
 }
        public void LengthTest()
        {
            const double expected = 12.57;
            double       actual   = m_Sut.Length;

            NUnitHelper.AssertIsEquivalent(expected,
                                           actual,
                                           0.01,
                                           "Length");
        }
Пример #5
0
        public void DistanceTest()
        {
            var pair = new CirclePair(m_Smaller,
                                      m_Bigger);

            NUnitHelper.AssertIsEquivalent(45.0,
                                           pair.Distance,
                                           0.01,
                                           "Distance");
        }
Пример #6
0
        public void DistanceTest()
        {
            const double expected = 2.83;
            double       actual   = m_One.Distance(m_Two);

            NUnitHelper.AssertIsEquivalent(expected,
                                           actual,
                                           0.01,
                                           "Distance");
        }
Пример #7
0
        public void DistanceTest()
        {
            var other = new Point(3.0,
                                  8.0);

            const double expected = 4.0;
            double       actual   = m_Point.DistanceTo(other);

            NUnitHelper.AssertIsEquivalent(expected,
                                           actual,
                                           "Distance");
        }
Пример #8
0
        public void Move45DegreesTest()
        {
            const double distance = 10.0;
            const double radians  = Angle.RadiansFor45Degrees;

            Point moved = m_Point.Move(distance,
                                       radians);

            NUnitHelper.AssertIsEquivalent(10.07,
                                           moved.X,
                                           "X");
            NUnitHelper.AssertIsEquivalent(11.07,
                                           moved.Y,
                                           "Y");
        }
Пример #9
0
        public void Move90DegreesTest()
        {
            const double distance = 10.0;
            const double radians  = BaseAngle.RadiansFor90Degrees;

            Point moved = m_Point.Move(distance,
                                       radians);

            NUnitHelper.AssertIsEquivalent(m_Point.X + 10.0,
                                           moved.X,
                                           "X");
            NUnitHelper.AssertIsEquivalent(m_Point.Y,
                                           moved.Y,
                                           "Y");
        }
Пример #10
0
        public void Length270DegreesTest()
        {
            var endPoint = new Point(6.0,
                                     3.0);

            var segment = new ArcSegment(m_Circle,
                                         m_StartPoint,
                                         endPoint);

            double actual = segment.LengthCounterClockwise;

            NUnitHelper.AssertIsEquivalent(18.85,
                                           actual,
                                           0.01,
                                           "Azimuth");
        }
Пример #11
0
        public void Length90DegreesTest()
        {
            var endPoint = new Point(6.0,
                                     3.0);

            var segment = new ArcSegment(m_Circle,
                                         m_StartPoint,
                                         endPoint);

            double actual = segment.LengthClockwise;

            NUnitHelper.AssertIsEquivalent(6.28,
                                           actual,
                                           0.01,
                                           "Distance");
        }
Пример #12
0
        private void AssertCalculateLengthForDegrees(double degrees)
        {
            const double radius        = 100.0;
            const double circumference = 2.0 * Math.PI * radius;

            double expected = circumference / (360.0 / degrees);
            Angle  radians  = Angle.FromDegrees(degrees);

            double actual = m_Sut.CalculateLength(radians,
                                                  radius);

            NUnitHelper.AssertIsEquivalent(expected,
                                           actual,
                                           0.01,
                                           "Length");
        }
Пример #13
0
        public void DistanceTo_CalculateDistance_ToOtherPoint()
        {
            // Arrange
            const double expected = 1.7320508075688772;

            var to = new Point(4.0,
                               5.0,
                               6.0);

            // Act
            double actual = m_Sut.DistanceTo(to);

            // Assert
            NUnitHelper.AssertIsEquivalent(expected,
                                           actual);
        }
        public static void AssertSphericalCoordinates(
            SphericalCoordinates expected,
            SphericalCoordinates actual)
        {
            Console.WriteLine("Expected: {0}".Inject(ConvertToSTring(expected)));
            Console.WriteLine("Actual:   {0}".Inject(ConvertToSTring(expected)));

            NUnitHelper.AssertIsEquivalent(expected.Radius,
                                           actual.Radius,
                                           "Radius");
            Assert.AreEqual(expected.Phi,
                            actual.Phi,
                            "Phi");
            Assert.AreEqual(expected.Theta,
                            actual.Theta,
                            "Theta");
        }
Пример #15
0
        private void AssertGetAngleRelativeToXAxis(double degrees,
                                                   double expectedDegrees)
        {
            // ReSharper disable MaximumChainedReferences
            double radians         = Angle.FromDegrees(degrees).Radians;
            double expectedRadians = Angle.FromDegrees(expectedDegrees).Radians;
            // ReSharper restore MaximumChainedReferences

            double x = m_CentrePoint.X + m_RadiusOne * Math.Cos(radians);
            double y = m_CentrePoint.Y + m_RadiusOne * Math.Sin(radians);

            var point = new Point(x,
                                  y);

            Angle actual = m_One.GetAngleRelativeToXAxis(point);

            NUnitHelper.AssertIsEquivalent(expectedRadians,
                                           actual.Radians,
                                           0.01,
                                           "Radians");
        }
        public void Calculate_SetsVectorInCartesian_ForGivenValues(
            double expectedRadius,
            double expectedPhiInRadians,
            double expectedThetaInRadians,
            double x,
            double y,
            double z)
        {
            // Arrange
            Angle expectedPhi   = Angle.FromRadians(expectedPhiInRadians);
            Angle expectedTheta = Angle.FromRadians(expectedThetaInRadians);

            var sut = new CartesianToSphericalCalculator();

            var cartesianCoordinates = new CartesianCoordinates
            {
                X = x,
                Y = y,
                Z = z
            };

            sut.CartesianCoordinates = cartesianCoordinates;

            // Act
            sut.Calculate();

            // Assert
            SphericalCoordinates actual = sut.SphericalCoordinates;

            NUnitHelper.AssertIsEquivalent(expectedRadius,
                                           actual.Radius,
                                           "Radius");

            NUnitHelper.AssertIsEquivalent(expectedPhi.Radians,
                                           actual.Phi.Radians,
                                           "Phi");
            NUnitHelper.AssertIsEquivalent(expectedTheta.Radians,
                                           actual.Theta.Radians,
                                           "Theta");
        }
        public void Calculate_SetsDistance_ForGivenPoints(
            [NotNull] PointDistanceCalculator sut)
        {
            // Arrange
            const double expected = 1.7320508075688772;

            var from = new Point(3.0,
                                 4.0,
                                 5.0);
            var to = new Point(4.0,
                               5.0,
                               6.0);

            sut.FromPoint = from;
            sut.ToPoint   = to;

            // Act
            sut.Calculate();

            // Assert
            NUnitHelper.AssertIsEquivalent(expected,
                                           sut.Distance);
        }
        public static void AssertCartesianCoordinates(
            CartesianCoordinates expected,
            CartesianCoordinates actual)
        {
            Console.WriteLine("Comparing CartesianCoordinates");
            Console.WriteLine("Expected: {0}",
                              CoordinatesToString(expected));
            Console.WriteLine("Actual  : {0}",
                              CoordinatesToString(actual));

            NUnitHelper.AssertIsEquivalent(expected.X,
                                           actual.X,
                                           Tolerance,
                                           "X");
            NUnitHelper.AssertIsEquivalent(expected.Y,
                                           actual.Y,
                                           Tolerance,
                                           "Y");
            NUnitHelper.AssertIsEquivalent(expected.Z,
                                           actual.Z,
                                           Tolerance,
                                           "Z");
        }