Пример #1
0
        public void TestDivisionByDuration()
        {
            Duration one = new Duration(1, 0.0);
            Duration two = new Duration(0, 60.0);

            Assert.AreEqual(86400.0 / 60.0, one.Divide(two), Constants.Epsilon10);
            Assert.AreEqual(60 / 86400.0, two / one, Constants.Epsilon10);

            Duration three = new Duration(1, 43200.0);

            Assert.AreEqual((86400 + 43200) / 60.0, three / two, Constants.Epsilon10);
            Assert.AreEqual(60.0 / (86400.0 + 43200.0), two.Divide(three), Constants.Epsilon10);

            Duration four = new Duration(1, 0);
            Duration five = new Duration(0, -3600);

            Assert.AreEqual(-24, four / five, Constants.Epsilon10);
            Assert.AreEqual((-1.0 / 24.0), five / four, Constants.Epsilon10);

            Duration six = new Duration(-2, 0);

            Assert.AreEqual(-0.5, four / six);
            Assert.AreEqual(48, six / five);

            Duration seven = new Duration(0, -0.5);

            Assert.AreEqual(-48 * 3600, four / seven);
        }
Пример #2
0
        public void TestDivisionByConstant()
        {
            Duration duration = new Duration(500, 100.0);
            Duration result   = duration.Divide(100.0);

            Assert.IsTrue(result.EqualsEpsilon(new Duration(5, 1.0), Constants.Epsilon10));
            result = duration / 100.0;
            Assert.IsTrue(result.EqualsEpsilon(new Duration(5, 1.0), Constants.Epsilon10));

            duration = new Duration(5, 68010.0);
            result   = duration.Divide(100.0);
            Assert.IsTrue(result.EqualsEpsilon(new Duration(0, 5000.1), Constants.Epsilon10));
            result = duration / 100.0;
            Assert.IsTrue(result.EqualsEpsilon(new Duration(0, 5000.1), Constants.Epsilon10));

            duration = new Duration(0, 64800.0);
            result   = duration.Divide(0.5);
            Assert.IsTrue(result.EqualsEpsilon(new Duration(1, 43200.0), Constants.Epsilon10));
            result = duration / 0.5;
            Assert.IsTrue(result.EqualsEpsilon(new Duration(1, 43200.0), Constants.Epsilon10));

            duration = new Duration(502, 43300.5);
            result   = duration.Divide(100.5);
            Assert.IsTrue(result.EqualsEpsilon(new Duration(5, 1.0), Constants.Epsilon10));
            result = duration / 100.5;
            Assert.IsTrue(result.EqualsEpsilon(new Duration(5, 1.0), Constants.Epsilon10));

            duration = new Duration(5, 1.0);
            result   = duration / -2.0;
            Assert.IsTrue(result.EqualsEpsilon(new Duration(-2, -43200.5), Constants.Epsilon10));

            duration = new Duration(0, 18 * 3600);
            result   = duration / -0.5;
            Assert.AreEqual(-12 * 3600, result.Seconds);
            Assert.AreEqual(-1, result.Days);

            duration = new Duration(1, 4 * 3600);
            result   = duration / -2;
            Assert.AreEqual(-14 * 3600, result.Seconds);
            Assert.AreEqual(0, result.Days);
        }
 public void OperatorDivision_MethodEquivalent()
 {
     Assert.AreEqual(threeMillion / 2000000, Duration.Divide(threeMillion, 2000000));
 }
Пример #4
0
 public void OperatorDivision_MethodEquivalent()
 {
     Assert.AreEqual(threeMillion / 2000000, Duration.Divide(threeMillion, 2000000));
     Assert.AreEqual(threeMillion / 2000000d, Duration.Divide(threeMillion, 2000000d));
     Assert.AreEqual(negativeFiftyMillion / threeMillion, Duration.Divide(negativeFiftyMillion, threeMillion));
 }