Beispiel #1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldReuseInstanceInArithmetics()
        public virtual void ShouldReuseInstanceInArithmetics()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final DateTimeValue datetime = datetime(date(2018, 2, 1), time(1, 17, 3, 0, UTC));
            DateTimeValue datetime = datetime(date(2018, 2, 1), time(1, 17, 3, 0, UTC));

            assertSame(datetime, datetime.Add(DurationValue.Duration(0, 0, 0, 0)));
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldApproximateWithoutAccumulatedRoundingErrors2()
        public virtual void ShouldApproximateWithoutAccumulatedRoundingErrors2()
        {
            double        months = 1.9013243104086859E-16; // 0.5 ns
            double        nanos  = 0.6;                    // with 1.1 ns we should be on the safe side to get rounded to 1 ns, even with rounding errors
            DurationValue result = DurationValue.Approximate(months, 0, 0, nanos);

            assertEqual(result, DurationValue.Duration(0, 0, 0, 1));
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReuseInstanceInArithmetics()
        internal virtual void ShouldReuseInstanceInArithmetics()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final TimeValue noon = time(12, 0, 0, 0, UTC);
            TimeValue noon = time(12, 0, 0, 0, UTC);

            assertSame(noon, noon.Add(DurationValue.Duration(0, 0, 0, 0)));
            assertSame(noon, noon.Add(DurationValue.Duration(1, 1, 0, 0)));
            assertSame(noon, noon.Add(DurationValue.Duration(-1, 1, 0, -0)));
        }
Beispiel #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldReuseInstanceInArithmetics()
        internal virtual void ShouldReuseInstanceInArithmetics()
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final DateValue date = date(2018, 2, 1);
            DateValue date = date(2018, 2, 1);

            assertSame(date, date.Add(DurationValue.Duration(0, 0, 0, 0)));
            assertSame(date, date.Add(DurationValue.Duration(0, 0, 1, 1)));
            assertSame(date, date.Add(DurationValue.Duration(-0, 0, 1, -1)));
        }
Beispiel #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldSubtractDurationFromDateTimes()
        public virtual void ShouldSubtractDurationFromDateTimes()
        {
            assertEquals(datetime(date(2018, 1, 1), time(1, 2, 3, 0, UTC)), datetime(date(2018, 2, 1), time(1, 17, 3, 0, UTC)).sub(DurationValue.Duration(1, 0, 900, 0)));
            assertEquals(datetime(date(2018, 1, 28), time(0, 0, 0, 0, UTC)), datetime(date(2018, 2, 28), time(0, 0, 0, 0, UTC)).sub(DurationValue.Duration(1, 0, 0, 0)));
            assertEquals(datetime(date(2018, 2, 28), time(0, 0, 0, 0, UTC)), datetime(date(2018, 1, 31), time(0, 0, 0, 0, UTC)).sub(DurationValue.Duration(-1, 0, 0, 0)));
        }
Beispiel #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldAddDurationToDateTimes()
        public virtual void ShouldAddDurationToDateTimes()
        {
            assertEquals(datetime(date(2018, 2, 1), time(1, 17, 3, 0, UTC)), datetime(date(2018, 1, 1), time(1, 2, 3, 0, UTC)).add(DurationValue.Duration(1, 0, 900, 0)));
            assertEquals(datetime(date(2018, 2, 28), time(0, 0, 0, 0, UTC)), datetime(date(2018, 1, 31), time(0, 0, 0, 0, UTC)).add(DurationValue.Duration(1, 0, 0, 0)));
            assertEquals(datetime(date(2018, 1, 28), time(0, 0, 0, 0, UTC)), datetime(date(2018, 2, 28), time(0, 0, 0, 0, UTC)).add(DurationValue.Duration(-1, 0, 0, 0)));
        }
Beispiel #7
0
 public override void WriteDuration(long months, long days, long seconds, int nanos)
 {
     Buffer.Add(DurationValue.Duration(months, days, seconds, nanos));
 }
Beispiel #8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldSubtractDurationFromTimes()
        internal virtual void ShouldSubtractDurationFromTimes()
        {
            assertEquals(time(12, 0, 0, 0, UTC), time(12, 15, 0, 0, UTC).sub(DurationValue.Duration(1, 1, 900, 0)));
            assertEquals(time(12, 0, 0, 0, UTC), time(12, 0, 2, 0, UTC).sub(DurationValue.Duration(0, 0, 1, 1_000_000_000)));
            assertEquals(time(12, 0, 0, 0, UTC), time(12, 0, 0, 0, UTC).sub(DurationValue.Duration(0, 0, 1, -1_000_000_000)));
        }
Beispiel #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldAddDurationToTimes()
        internal virtual void ShouldAddDurationToTimes()
        {
            assertEquals(time(12, 15, 0, 0, UTC), time(12, 0, 0, 0, UTC).add(DurationValue.Duration(1, 1, 900, 0)));
            assertEquals(time(12, 0, 2, 0, UTC), time(12, 0, 0, 0, UTC).add(DurationValue.Duration(0, 0, 1, 1_000_000_000)));
            assertEquals(time(12, 0, 0, 0, UTC), time(12, 0, 0, 0, UTC).add(DurationValue.Duration(0, 0, 1, -1_000_000_000)));
        }
Beispiel #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldApproximateWithoutAccumulatedRoundingErrors()
        public virtual void ShouldApproximateWithoutAccumulatedRoundingErrors()
        {
            DurationValue result = DurationValue.Approximate(10.8, 0, 0, 0);

            assertEqual(result, DurationValue.Duration(10, 24, 30196, 800000000));
        }
Beispiel #11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldHandleLargeNanos()
        internal virtual void ShouldHandleLargeNanos()
        {
            DurationValue duration = DurationValue.Duration(0L, 0L, 0L, long.MaxValue);

            assertEquals(long.MaxValue, duration.Get("nanoseconds").value());
        }
Beispiel #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldSubtractDurationFromDates()
        internal virtual void ShouldSubtractDurationFromDates()
        {
            assertEquals(date(2018, 1, 1), date(2018, 2, 1).sub(DurationValue.Duration(1, 0, 900, 0)));
            assertEquals(date(2018, 1, 28), date(2018, 2, 28).sub(DurationValue.Duration(1, 0, 0, 0)));
            assertEquals(date(2018, 2, 28), date(2018, 1, 31).sub(DurationValue.Duration(-1, 0, 0, 0)));
        }
Beispiel #13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldAddDurationToDates()
        internal virtual void ShouldAddDurationToDates()
        {
            assertEquals(date(2018, 2, 1), date(2018, 1, 1).add(DurationValue.Duration(1, 0, 900, 0)));
            assertEquals(date(2018, 2, 28), date(2018, 1, 31).add(DurationValue.Duration(1, 0, 0, 0)));
            assertEquals(date(2018, 1, 28), date(2018, 2, 28).add(DurationValue.Duration(-1, 0, 0, 0)));
        }