Example #1
0
        public void TestInchAddOn()
        {
            MillimeterUnit mil  = 100d;
            MeterUnit      met  = 10d;
            KilometerUnit  kmet = 1d;
            MileUnit       mile = 0.5d;
            InchUnit       inch = 25d;

            Assert.AreEqual(25d + (100d / InchUnit.InchToMilimeters), (inch + mil).Value);
            Assert.AreEqual(25d - (100d / InchUnit.InchToMilimeters), (inch - mil).Value);
            Assert.AreEqual(25d * (100d / InchUnit.InchToMilimeters), (inch * mil).Value);
            Assert.AreEqual(25d / (100d / InchUnit.InchToMilimeters), (inch / mil).Value);

            Assert.AreEqual(25d + (10d * 1000d / InchUnit.InchToMilimeters), (inch + met).Value);
            Assert.AreEqual(25d - (10d * 1000d / InchUnit.InchToMilimeters), (inch - met).Value);
            Assert.AreEqual(25d * (10d * 1000d / InchUnit.InchToMilimeters), (inch * met).Value);
            Assert.AreEqual(25d / (10d * 1000d / InchUnit.InchToMilimeters), (inch / met).Value);

            Assert.AreEqual(25d + (1d * 1000 * 1000 / InchUnit.InchToMilimeters), (inch + kmet).Value);
            Assert.AreEqual(25d - (1d * 1000 * 1000 / InchUnit.InchToMilimeters), (inch - kmet).Value);
            Assert.AreEqual(25d * (1d * 1000 * 1000 / InchUnit.InchToMilimeters), (inch * kmet).Value);
            Assert.AreEqual(25d / (1d * 1000 * 1000 / InchUnit.InchToMilimeters), (inch / kmet).Value);

            Assert.AreEqual(25d + (0.5d * MileUnit.MileToKilometers * 1000 * 1000 / InchUnit.InchToMilimeters), (inch + mile).Value);
            Assert.AreEqual(25d - (0.5d * MileUnit.MileToKilometers * 1000 * 1000 / InchUnit.InchToMilimeters), (inch - mile).Value);
            Assert.AreEqual(25d * (0.5d * MileUnit.MileToKilometers * 1000 * 1000 / InchUnit.InchToMilimeters), (inch * mile).Value);
            Assert.AreEqual(25d / (0.5d * MileUnit.MileToKilometers * 1000 * 1000 / InchUnit.InchToMilimeters), (inch / mile).Value);
        }
Example #2
0
        public void TestMileAddOn()
        {
            MillimeterUnit mil  = 100d;
            MeterUnit      met  = 10d;
            KilometerUnit  kmet = 1d;
            MileUnit       mile = 0.5d;
            InchUnit       inch = 25d;

            Assert.AreEqual(0.5d + (100d / 1000d / 1000d / MileUnit.MileToKilometers), (mile + mil).Value);
            Assert.AreEqual(0.5d - (100d / 1000d / 1000d / MileUnit.MileToKilometers), (mile - mil).Value);
            Assert.AreEqual(0.5d * (100d / 1000d / 1000d / MileUnit.MileToKilometers), (mile * mil).Value);
            Assert.AreEqual(0.5d / (100d / 1000d / 1000d / MileUnit.MileToKilometers), (mile / mil).Value);

            Assert.AreEqual(0.5d + (10d / 1000d / MileUnit.MileToKilometers), (mile + met).Value);
            Assert.AreEqual(0.5d - (10d / 1000d / MileUnit.MileToKilometers), (mile - met).Value);
            Assert.AreEqual(0.5d * (10d / 1000d / MileUnit.MileToKilometers), (mile * met).Value);
            Assert.AreEqual(0.5d / (10d / 1000d / MileUnit.MileToKilometers), (mile / met).Value);

            Assert.AreEqual(0.5d + (1d / MileUnit.MileToKilometers), (mile + kmet).Value);
            Assert.AreEqual(0.5d - (1d / MileUnit.MileToKilometers), (mile - kmet).Value);
            Assert.AreEqual(0.5d * (1d / MileUnit.MileToKilometers), (mile * kmet).Value);
            Assert.AreEqual(0.5d / (1d / MileUnit.MileToKilometers), (mile / kmet).Value);

            Assert.AreEqual(0.5d + (25d * InchUnit.InchToMilimeters / 1000 / 1000 / MileUnit.MileToKilometers), (mile + inch).Value);
            Assert.AreEqual(0.5d - (25d * InchUnit.InchToMilimeters / 1000 / 1000 / MileUnit.MileToKilometers), (mile - inch).Value);
            Assert.AreEqual(0.5d * (25d * InchUnit.InchToMilimeters / 1000 / 1000 / MileUnit.MileToKilometers), (mile * inch).Value);
            Assert.AreEqual(0.5d / (25d * InchUnit.InchToMilimeters / 1000 / 1000 / MileUnit.MileToKilometers), (mile / inch).Value);
        }
Example #3
0
        public void TestKilometerAddOn()
        {
            MillimeterUnit mil  = 100d;
            MeterUnit      met  = 10d;
            KilometerUnit  kmet = 1d;
            MileUnit       mile = 0.5d;
            InchUnit       inch = 25d;

            Assert.AreEqual(1d + (100d / 1000d / 1000d), (kmet + mil).Value);
            Assert.AreEqual(1d - (100d / 1000d / 1000d), (kmet - mil).Value);
            Assert.AreEqual(1d * (100d / 1000d / 1000d), (kmet * mil).Value);
            Assert.AreEqual(1d / (100d / 1000d / 1000d), (kmet / mil).Value);

            Assert.AreEqual(1d + (10d / 1000d), (kmet + met).Value);
            Assert.AreEqual(1d - (10d / 1000d), (kmet - met).Value);
            Assert.AreEqual(1d * (10d / 1000d), (kmet * met).Value);
            Assert.AreEqual(1d / (10d / 1000d), (kmet / met).Value);

            Assert.AreEqual(1d + (0.5d * MileUnit.MileToKilometers), (kmet + mile).Value);
            Assert.AreEqual(1d - (0.5d * MileUnit.MileToKilometers), (kmet - mile).Value);
            Assert.AreEqual(1d * (0.5d * MileUnit.MileToKilometers), (kmet * mile).Value);
            Assert.AreEqual(1d / (0.5d * MileUnit.MileToKilometers), (kmet / mile).Value);

            Assert.AreEqual(1d + (25d * InchUnit.InchToMilimeters / 1000 / 1000), (kmet + inch).Value);
            Assert.AreEqual(1d - (25d * InchUnit.InchToMilimeters / 1000 / 1000), (kmet - inch).Value);
            Assert.AreEqual(1d * (25d * InchUnit.InchToMilimeters / 1000 / 1000), (kmet * inch).Value);
            Assert.AreEqual(1d / (25d * InchUnit.InchToMilimeters / 1000 / 1000), (kmet / inch).Value);
        }
Example #4
0
        public void TestMillimeterAddOn()
        {
            MillimeterUnit mil  = 100d;
            MeterUnit      met  = 10d;
            KilometerUnit  kmet = 1d;
            MileUnit       mile = 0.5d;
            InchUnit       inch = 25d;

            Assert.AreEqual(100d + (10d * 1000d), (mil + met).Value);
            Assert.AreEqual(100d - (10d * 1000d), (mil - met).Value);
            Assert.AreEqual(100d * (10d * 1000d), (mil * met).Value);
            Assert.AreEqual(100d / (10d * 1000d), (mil / met).Value);

            Assert.AreEqual(100d + (1d * 1000d * 1000d), (mil + kmet).Value);
            Assert.AreEqual(100d - (1d * 1000d * 1000d), (mil - kmet).Value);
            Assert.AreEqual(100d * (1d * 1000d * 1000d), (mil * kmet).Value);
            Assert.AreEqual(100d / (1d * 1000d * 1000d), (mil / kmet).Value);

            Assert.AreEqual(100d + (0.5d * MileUnit.MileToKilometers * 1000d * 1000d), (mil + mile).Value);
            Assert.AreEqual(100d - (0.5d * MileUnit.MileToKilometers * 1000d * 1000d), (mil - mile).Value);
            Assert.AreEqual(100d * (0.5d * MileUnit.MileToKilometers * 1000d * 1000d), (mil * mile).Value);
            Assert.AreEqual(100d / (0.5d * MileUnit.MileToKilometers * 1000d * 1000d), (mil / mile).Value);

            Assert.AreEqual(100d + (25d * InchUnit.InchToMilimeters), (mil + inch).Value);
            Assert.AreEqual(100d - (25d * InchUnit.InchToMilimeters), (mil - inch).Value);
            Assert.AreEqual(100d * (25d * InchUnit.InchToMilimeters), (mil * inch).Value);
            Assert.AreEqual(100d / (25d * InchUnit.InchToMilimeters), (mil / inch).Value);
        }
Example #5
0
        public void TestKilometer()
        {
            KilometerUnit val1 = 100d;
            KilometerUnit val2 = 10d;

            Assert.AreEqual(110d, (val1 + val2).Value);
            Assert.AreEqual(90d, (val1 - val2).Value);
            Assert.AreEqual(1000d, (val1 * val2).Value);
            Assert.AreEqual(10d, (val1 / val2).Value);
        }
Example #6
0
        public void TestLengthUnitConditions()
        {
            MillimeterUnit mil  = 100d;
            MeterUnit      met  = 10d;
            KilometerUnit  kmet = 1d;
            MileUnit       mile = 0.5d;
            InchUnit       inch = 25d;

            //**********************

            Assert.IsTrue(mil < met);
            Assert.IsTrue(met > mil);
            Assert.IsFalse(mil > met);
            Assert.IsFalse(met < mil);

            Assert.IsTrue(mil < kmet);
            Assert.IsTrue(kmet > mil);
            Assert.IsFalse(mil > kmet);
            Assert.IsFalse(kmet < mil);

            Assert.IsTrue(mil < mile);
            Assert.IsTrue(mile > mil);
            Assert.IsFalse(mil > mile);
            Assert.IsFalse(mile < mil);

            Assert.IsTrue(mil < inch);
            Assert.IsTrue(inch > mil);
            Assert.IsFalse(mil > inch);
            Assert.IsFalse(inch < mil);

            //************************

            Assert.IsTrue(met < kmet);
            Assert.IsTrue(kmet > met);
            Assert.IsFalse(met > kmet);
            Assert.IsFalse(kmet < met);

            Assert.IsTrue(met < mile);
            Assert.IsTrue(mile > met);
            Assert.IsFalse(met > mile);
            Assert.IsFalse(mile < met);

            Assert.IsTrue(met > inch);
            Assert.IsTrue(inch < met);
            Assert.IsFalse(met < inch);
            Assert.IsFalse(inch > met);

            //************************

            Assert.IsTrue(kmet > mile);
            Assert.IsTrue(mile < kmet);
            Assert.IsFalse(kmet < mile);
            Assert.IsFalse(mile > kmet);

            Assert.IsTrue(kmet > inch);
            Assert.IsTrue(inch < kmet);
            Assert.IsFalse(kmet < inch);
            Assert.IsFalse(inch > kmet);

            //************************

            Assert.IsTrue(mile > inch);
            Assert.IsTrue(inch < mile);
            Assert.IsFalse(mile < inch);
            Assert.IsFalse(inch > mile);
        }