Пример #1
0
        public void EqualsIsImplemented()
        {
            Length2d v = Length2d.FromMeters(1, 2);

            Assert.IsTrue(v.Equals(Length2d.FromMeters(1, 2)));
            Assert.IsFalse(v.Equals(Length2d.Zero));
        }
Пример #2
0
        // Method overloads with same number of argumnets not supported in Universal Windows Platform (WinRT Components)
#if !WINDOWS_UWP
        public static Force FromPressureByArea(Pressure p, Length2d area)
        {
            double metersSquared = area.Meters.X * area.Meters.Y;
            double newtons       = p.Pascals * metersSquared;

            return(new Force(newtons));
        }
Пример #3
0
        public void EqualityOperators()
        {
            Length2d a = Length2d.FromMeters(1, 2);
            Length2d b = Length2d.FromMeters(2, 1);

            // ReSharper disable EqualExpressionComparison
            // Disable build warning: Comparison made to same variable; did you mean to compare something else?
#pragma warning disable 1718
            Assert.True(a == a);
            Assert.True(a != b);

            Assert.False(a == b);
            Assert.False(a != a);
#pragma warning restore 1718
            // ReSharper restore EqualExpressionComparison
        }
Пример #4
0
        public void ArithmeticOperators()
        {
            Length2d v = Length2d.FromMeters(1, 2);

            Assert.AreEqual(-1, -v.Meters.X, Delta);
            Assert.AreEqual(-2, -v.Meters.Y, Delta);
            Assert.AreEqual(2, (Length2d.FromMeters(3, 3) - v).Meters.X, Delta);
            Assert.AreEqual(1, (Length2d.FromMeters(3, 3) - v).Meters.Y, Delta);
            Assert.AreEqual(2, (v + v).Meters.X, Delta);
            Assert.AreEqual(4, (v + v).Meters.Y, Delta);
            Assert.AreEqual(10, (v * 10).Meters.X, Delta);
            Assert.AreEqual(20, (v * 10).Meters.Y, Delta);
            Assert.AreEqual(10, (10 * v).Meters.X, Delta);
            Assert.AreEqual(20, (10 * v).Meters.Y, Delta);
            Assert.AreEqual(2, (Length2d.FromMeters(2, 2) * v).Meters.X, Delta);
            Assert.AreEqual(4, (Length2d.FromMeters(2, 2) * v).Meters.Y, Delta);
            Assert.AreEqual(2, (Length2d.FromMeters(10, 20) / 5).Meters.X, Delta);
            Assert.AreEqual(4, (Length2d.FromMeters(10, 20) / 5).Meters.Y, Delta);
            Assert.AreEqual(2, (Length2d.FromMeters(10, 20) / Length2d.FromMeters(5, 5)).X, Delta);
            Assert.AreEqual(4, (Length2d.FromMeters(10, 20) / Length2d.FromMeters(5, 5)).Y, Delta);
        }
Пример #5
0
        public void MetersToDistanceUnits()
        {
            Length2d meter = Length2d.FromMeters(1, 1);

            AssertAreEqual(new Vector2(1), meter.Meters, Delta);
            AssertAreEqual(new Vector2(1E2), meter.Centimeters, Delta);
            AssertAreEqual(new Vector2(1E3), meter.Millimeters, Delta);
            AssertAreEqual(new Vector2(1E-3), meter.Kilometers, Delta);
            AssertAreEqual(new Vector2(1), meter.Meters, Delta);
            AssertAreEqual(new Vector2(1E1), meter.Decimeters, Delta);
            AssertAreEqual(new Vector2(1E2), meter.Centimeters, Delta);
            AssertAreEqual(new Vector2(1E3), meter.Millimeters, Delta);
            AssertAreEqual(new Vector2(1E6), meter.Micrometers, Delta);
            AssertAreEqual(new Vector2(1E9), meter.Nanometers, Delta);

            Assert.AreEqual(0.000621371, meter.Miles.X, Delta);
            Assert.AreEqual(0.000621371, meter.Miles.Y, Delta);
            Assert.AreEqual(1.09361, meter.Yards.X, Delta);
            Assert.AreEqual(1.09361, meter.Yards.Y, Delta);
            Assert.AreEqual(3.28084, meter.Feet.X, Delta);
            Assert.AreEqual(3.28084, meter.Feet.Y, Delta);
            Assert.AreEqual(39.37007874, meter.Inches.X, Delta);
            Assert.AreEqual(39.37007874, meter.Inches.Y, Delta);
        }
Пример #6
0
        public void PressureByAreaEqualsForceUsingLength2D()
        {
            var force = Force.FromPressureByArea(Pressure.FromNewtonsPerSquareMeter(6), Length2d.FromMeters(5, 2));

            Assert.AreEqual(force, Force.FromNewtons(60));
        }
Пример #7
0
        // Method overloads with same number of argumnets not supported in Universal Windows Platform (WinRT Components)
#if !WINDOWS_UWP
        public static Force FromPressureByArea(Pressure p, Length2d area)
        {
            double metersSquared = area.Meters.X*area.Meters.Y;
            double newtons = p.Pascals*metersSquared;
            return new Force(newtons);
        }
Пример #8
0
        public void VectorLength()
        {
            var v = new Length2d(3, 4);

            Assert.AreEqual(5, v.Length.Meters);
        }
Пример #9
0
        public void EqualsReturnsFalseOnTypeMismatch()
        {
            Length2d newton = Length2d.FromMeters(1, 2);

            Assert.IsFalse(newton.Equals(new object()));
        }
Пример #10
0
        public void EqualsReturnsFalseOnNull()
        {
            Length2d newton = Length2d.FromMeters(1, 2);

            Assert.IsFalse(newton.Equals(null));
        }
Пример #11
0
 public void VectorLength()
 {
     var v = new Length2d(3, 4);
     Assert.AreEqual(5, v.Length.Meters);
 }