Exemplo n.º 1
0
 private static void AssertImpossible(LocalDateTime localTime, DateTimeZone zone)
 {
     try
     {
         zone.AtExactly(localTime);
         Assert.Fail("Expected exception");
     }
     catch (SkippedTimeException e)
     {
         Assert.AreEqual(localTime, e.LocalDateTime);
         Assert.AreEqual(zone, e.Zone);
     }
 }
Exemplo n.º 2
0
        private static void AssertAmbiguous(LocalDateTime localTime, DateTimeZone zone)
        {
            ZonedDateTime earlier = zone.AtEarlier(localTime);
            ZonedDateTime later = zone.AtLater(localTime);
            Assert.AreEqual(localTime, earlier.LocalDateTime);
            Assert.AreEqual(localTime, later.LocalDateTime);
            Assert.That(earlier.ToInstant(), Is.LessThan(later.ToInstant()));

            try
            {
                zone.AtExactly(localTime);
                Assert.Fail("Expected exception");
            }
            catch (AmbiguousTimeException e)
            {
                Assert.AreEqual(localTime, e.LocalDateTime);
                Assert.AreEqual(zone, e.Zone);
                Assert.AreEqual(earlier, e.EarlierMapping);
                Assert.AreEqual(later, e.LaterMapping);
            }
        }
Exemplo n.º 3
0
 private static void AssertOffset(int expectedHours, LocalDateTime localTime, DateTimeZone zone)
 {
     var zoned = zone.AtExactly(localTime);
     int actualHours = zoned.Offset.TotalMilliseconds / NodaConstants.MillisecondsPerHour;
     Assert.AreEqual(expectedHours, actualHours);
 }