Ejemplo n.º 1
0
        public void NodaTimeBuilder_Initialize_UTC_Datetime_Now_Subtract_Day_Should_Rollback_To_LastDay_Previous_Year()
        {
            //1970-01-01 00:00:00.000 to 1969-12-31 00:00:00.000.
            var instant = new NodaTimeBuilder(new FakeDateTime().UtcNow).SubtractDays(1)
                          .Build();

            var dt = instant.ToDateTimeUtc();

            Assert.Equal(1969, dt.Year);
            Assert.Equal(12, dt.Month);
            Assert.Equal(31, dt.Day);
        }
Ejemplo n.º 2
0
        public void NodaTimeBuilder_If_Add_Add_Subtract_Same_Value_Days_Should_Not_Change_Date()
        {
            var instant = new NodaTimeBuilder(this.clock).AddDays(1)
                          .SubtractDays(1)
                          .Build();

            var dt = instant.ToDateTimeUtc();

            Assert.Equal(DateTimeKind.Utc, dt.Kind);
            Assert.Equal(1970, dt.Year);
            Assert.Equal(1, dt.Month);
            Assert.Equal(1, dt.Day);
            Assert.Equal(0, dt.Hour);
            Assert.Equal(0, dt.Minute);
            Assert.Equal(0, dt.Second);
            Assert.Equal(0, dt.Millisecond);
        }