public void One_hour_tick_interval() { var tickInterval = GetFirstTickIntervalWithGreaterDuration(Duration.Zero); tickInterval.ShouldNotBeNull(); var d1 = ExactDateInfo.AnnoDomini(100, 2, 3, 12); var d2 = ExactDateInfo.AnnoDomini(100, 2, 3, 14); var ticks = tickInterval.GetTicksBetween(d1, d2).ToArray(); ticks.Length.ShouldBe(3); ticks[0].Date.ShouldBe(d1); ticks[1].Date.ShouldBe(ExactDateInfo.AnnoDomini(100, 2, 3, 13)); ticks[2].Date.ShouldBe(d2); d1 = ExactDateInfo.BeforeChrist(100, 2, 3, 12); d2 = ExactDateInfo.BeforeChrist(100, 2, 3, 14); ticks = tickInterval.GetTicksBetween(d1, d2).ToArray(); ticks.Length.ShouldBe(3); ticks[0].Date.ShouldBe(d1); ticks[1].Date.ShouldBe(ExactDateInfo.BeforeChrist(100, 2, 3, 13)); ticks[2].Date.ShouldBe(d2); }
public void One_year_tick_interval() { var tickInterval = GetFirstTickIntervalWithGreaterDuration(Duration.Zero.AddMonths(8)); tickInterval.ShouldNotBeNull(); var d1 = ExactDateInfo.AnnoDomini(100, 1, 1, 0); var d2 = ExactDateInfo.AnnoDomini(102, 1, 1, 0); var ticks = tickInterval.GetTicksBetween(d1, d2).ToArray(); ticks.Length.ShouldBe(3); ticks[0].Date.ShouldBe(d1); ticks[1].Date.ShouldBe(ExactDateInfo.AnnoDomini(101, 1, 1, 0)); ticks[2].Date.ShouldBe(d2); d1 = ExactDateInfo.AnnoDomini(100, 3, 3, 5); d2 = ExactDateInfo.AnnoDomini(104, 8, 5, 17); ticks = tickInterval.GetTicksBetween(d1, d2).ToArray(); ticks.Length.ShouldBe(4); ticks[0].Date.ShouldBe(ExactDateInfo.AnnoDomini(101, 1, 1, 0)); ticks[1].Date.ShouldBe(ExactDateInfo.AnnoDomini(102, 1, 1, 0)); ticks[2].Date.ShouldBe(ExactDateInfo.AnnoDomini(103, 1, 1, 0)); ticks[3].Date.ShouldBe(ExactDateInfo.AnnoDomini(104, 1, 1, 0)); d1 = ExactDateInfo.BeforeChrist(100, 3, 3, 5); d2 = ExactDateInfo.BeforeChrist(97, 8, 5, 17); ticks = tickInterval.GetTicksBetween(d1, d2).ToArray(); ticks.Length.ShouldBe(3); ticks[0].Date.ShouldBe(ExactDateInfo.BeforeChrist(99, 1, 1, 0)); ticks[1].Date.ShouldBe(ExactDateInfo.BeforeChrist(98, 1, 1, 0)); ticks[2].Date.ShouldBe(ExactDateInfo.BeforeChrist(97, 1, 1, 0)); d1 = ExactDateInfo.BeforeChrist(2, 3, 3, 5); d2 = ExactDateInfo.AnnoDomini(2, 8, 5, 17); ticks = tickInterval.GetTicksBetween(d1, d2).ToArray(); ticks.Length.ShouldBe(3); ticks[0].Date.ShouldBe(ExactDateInfo.BeforeChrist(1, 1, 1, 0)); ticks[1].Date.ShouldBe(ExactDateInfo.AnnoDomini(1, 1, 1, 0)); ticks[2].Date.ShouldBe(ExactDateInfo.AnnoDomini(2, 1, 1, 0)); d1 = ExactDateInfo.AnnoDomini(1, 3, 3, 5); d2 = ExactDateInfo.AnnoDomini(2, 8, 5, 17); ticks = tickInterval.GetTicksBetween(d1, d2).ToArray(); ticks.Length.ShouldBe(1); ticks[0].Date.ShouldBe(ExactDateInfo.AnnoDomini(2, 1, 1, 0)); }
public void Several_years_tick_interval(long years) { var tickInterval = GetFirstTickIntervalWithGreaterDuration(Duration.Zero.AddYears(years).AddMonths(-1)); tickInterval.ShouldNotBeNull(); var d1 = ExactDateInfo.AnnoDomini(years, 1, 1, 0); var d2 = ExactDateInfo.AnnoDomini(3 * years, 1, 1, 0); var ticks = tickInterval.GetTicksBetween(d1, d2).ToArray(); ticks.Length.ShouldBe(3); ticks[0].Date.ShouldBe(d1); ticks[1].Date.ShouldBe(ExactDateInfo.AnnoDomini(years * 2, 1, 1, 0)); ticks[2].Date.ShouldBe(d2); d1 = ExactDateInfo.AnnoDomini(years, 3, 3, 5); d2 = ExactDateInfo.AnnoDomini(years * 4, 8, 5, 17); ticks = tickInterval.GetTicksBetween(d1, d2).ToArray(); ticks.Length.ShouldBe(3); ticks[0].Date.ShouldBe(ExactDateInfo.AnnoDomini(years * 2, 1, 1, 0)); ticks[1].Date.ShouldBe(ExactDateInfo.AnnoDomini(years * 3, 1, 1, 0)); ticks[2].Date.ShouldBe(ExactDateInfo.AnnoDomini(years * 4, 1, 1, 0)); d1 = ExactDateInfo.BeforeChrist(years * 4, 3, 3, 5); d2 = ExactDateInfo.BeforeChrist(years * 1, 8, 5, 17); ticks = tickInterval.GetTicksBetween(d1, d2).ToArray(); ticks.Length.ShouldBe(3); ticks[0].Date.ShouldBe(ExactDateInfo.BeforeChrist(years * 3, 1, 1, 0)); ticks[1].Date.ShouldBe(ExactDateInfo.BeforeChrist(years * 2, 1, 1, 0)); ticks[2].Date.ShouldBe(ExactDateInfo.BeforeChrist(years * 1, 1, 1, 0)); d1 = ExactDateInfo.BeforeChrist(years * 2, 3, 3, 5); d2 = ExactDateInfo.AnnoDomini(years * 1, 8, 5, 17); ticks = tickInterval.GetTicksBetween(d1, d2).ToArray(); ticks.Length.ShouldBe(3); ticks[0].Date.ShouldBe(ExactDateInfo.BeforeChrist(years * 1, 1, 1, 0)); ticks[1].Date.ShouldBe(ExactDateInfo.AnnoDomini(1, 1, 1, 0)); ticks[2].Date.ShouldBe(ExactDateInfo.AnnoDomini(years * 1, 1, 1, 0)); }
public async Task Get_events_from_time_range_with_only_start_in_range() { // Act var eventsInTimeRange = await _fixture.EventsRepo.GetEventsAsync( InRange( ExactDateInfo.BeforeChrist(20, 1, 1, 0), ExactDateInfo.AnnoDomini(1, 1, 1, 0) ) ); // Assert eventsInTimeRange.ShouldNotBeNull(); eventsInTimeRange.Count.ShouldBe(2); eventsInTimeRange.ShouldContain(e => e.Description == "A"); eventsInTimeRange.ShouldContain(e => e.Description == "B"); }
public async Task Get_events_when_there_are_no_events_that_meet_both_conditions() { // Act var eventsInTimeRange = await _fixture.EventsRepo.GetEventsAsync( InRange( ExactDateInfo.BeforeChrist(20, 1, 1, 0), ExactDateInfo.BeforeChrist(20, 10, 1, 0) ).And( InRange( ExactDateInfo.BeforeChrist(100, 2, 3, 1), ExactDateInfo.BeforeChrist(100, 2, 3, 21) ) ) ); // Assert eventsInTimeRange.ShouldNotBeNull(); eventsInTimeRange.ShouldBeEmpty(); }
public async Task Get_events_when_there_are_events_that_meet_both_conditions() { // Act var eventsInTimeRange = await _fixture.EventsRepo.GetEventsAsync( InRange( ExactDateInfo.BeforeChrist(20, 1, 1, 0), ExactDateInfo.BeforeChrist(20, 10, 1, 0) ).Or( InRange( ExactDateInfo.BeforeChrist(30, 1, 1, 0), ExactDateInfo.BeforeChrist(10, 1, 1, 0) ) ) ); // Assert eventsInTimeRange.ShouldNotBeNull(); eventsInTimeRange.Count.ShouldBe(1); eventsInTimeRange[0].Description.ShouldBe("B"); }
public async Task Get_events_from_time_range_with_full_events() { // Act var eventsInTimeRange = await _fixture.EventsRepo.GetEventsAsync( InRange( ExactDateInfo.BeforeChrist(20, 1, 1, 0), ExactDateInfo.BeforeChrist(20, 12, 1, 0) ) ); // Assert eventsInTimeRange.ShouldNotBeNull(); eventsInTimeRange.Count.ShouldBe(1); var @event = eventsInTimeRange[0]; @event.ShouldNotBeNull(); @event.Description.ShouldBe("B"); }
public async Task Revert_specification() { // Act var eventsInTimeRange = await _fixture.EventsRepo.GetEventsAsync( Not( InRange( ExactDateInfo.BeforeChrist(20, 1, 1, 0), ExactDateInfo.AnnoDomini(1, 1, 1, 0) ) ) ); // Assert eventsInTimeRange.ShouldNotBeNull(); eventsInTimeRange.Count.ShouldBe(3); eventsInTimeRange.ShouldContain(e => e.Description == "C"); eventsInTimeRange.ShouldContain(e => e.Description == "D"); eventsInTimeRange.ShouldContain(e => e.Description == "E"); }
public void One_month_tick_interval() { var tickInterval = GetFirstTickIntervalWithGreaterDuration(Duration.Zero.AddDays(20)); tickInterval.ShouldNotBeNull(); var d1 = ExactDateInfo.AnnoDomini(100, 2, 1, 0); var d2 = ExactDateInfo.AnnoDomini(100, 5, 1, 0); var ticks = tickInterval.GetTicksBetween(d1, d2).ToArray(); ticks.Length.ShouldBe(4); ticks[0].Date.ShouldBe(d1); ticks[1].Date.ShouldBe(ExactDateInfo.AnnoDomini(100, 3, 1, 0)); ticks[2].Date.ShouldBe(ExactDateInfo.AnnoDomini(100, 4, 1, 0)); ticks[3].Date.ShouldBe(d2); d1 = ExactDateInfo.AnnoDomini(100, 3, 3, 5); d2 = ExactDateInfo.AnnoDomini(100, 5, 5, 17); ticks = tickInterval.GetTicksBetween(d1, d2).ToArray(); ticks.Length.ShouldBe(2); ticks[0].Date.ShouldBe(ExactDateInfo.AnnoDomini(100, 4, 1, 0)); ticks[1].Date.ShouldBe(ExactDateInfo.AnnoDomini(100, 5, 1, 0)); d1 = ExactDateInfo.BeforeChrist(100, 11, 3, 5); d2 = ExactDateInfo.BeforeChrist(99, 2, 5, 17); ticks = tickInterval.GetTicksBetween(d1, d2).ToArray(); ticks.Length.ShouldBe(3); ticks[0].Date.ShouldBe(ExactDateInfo.BeforeChrist(100, 12, 1, 0)); ticks[1].Date.ShouldBe(ExactDateInfo.BeforeChrist(99, 1, 1, 0)); ticks[2].Date.ShouldBe(ExactDateInfo.BeforeChrist(99, 2, 1, 0)); }
public async Task Get_events_when_there_are_no_events_that_meet_both_conditions() { // Act var eventsInTimeRange = await _fixture.EventsRepo.GetEventsAsync( InRange( ExactDateInfo.BeforeChrist(20, 1, 1, 0), ExactDateInfo.BeforeChrist(20, 10, 1, 0) ).Or( InRange( ExactDateInfo.BeforeChrist(100, 2, 3, 1), ExactDateInfo.BeforeChrist(100, 2, 3, 21) ) ) ); // Assert eventsInTimeRange.ShouldNotBeNull(); eventsInTimeRange.Count.ShouldBe(2); eventsInTimeRange.ShouldContain(e => e.Description == "B"); eventsInTimeRange.ShouldContain(e => e.Description == "E"); }
public static IEnumerable <object[]> AddDurationToDateData() { yield return(new object[] { ExactDateInfo.AnnoDomini(100, 1, 1, 0), Duration.Zero.AddYears(50), ExactDateInfo.AnnoDomini(150, 1, 1, 0) }); yield return(new object[] { ExactDateInfo.BeforeChrist(26, 1, 1, 0), Duration.Zero.AddYears(50), ExactDateInfo.AnnoDomini(25, 1, 1, 0) }); yield return(new object[] { ExactDateInfo.AnnoDomini(10, 1, 1, 0), Duration.Zero.AddYears(-50), ExactDateInfo.BeforeChrist(41, 1, 1, 0) }); }
public static IEnumerable <object[]> DurationToDateData() { yield return(new object[] { Duration.Zero, ExactDateInfo.AnnoDomini(1, 1, 1, 0) }); yield return(new object[] { Duration.Zero.AddYears(5), ExactDateInfo.AnnoDomini(6, 1, 1, 0) }); yield return(new object[] { Duration.Zero.AddMonths(3), ExactDateInfo.AnnoDomini(1, 4, 1, 0) }); yield return(new object[] { Duration.Zero.AddDays(13), ExactDateInfo.AnnoDomini(1, 1, 14, 0) }); yield return(new object[] { Duration.Zero.AddHours(20), ExactDateInfo.AnnoDomini(1, 1, 1, 20) }); yield return(new object[] { Duration.Zero .AddYears(1000000 - 1) .AddMonths(12 - 1) .AddDays(31 - 1) .AddHours(23), ExactDateInfo.AnnoDomini(1000000, 12, 31, 23) }); yield return(new object[] { Duration.Zero.AddYears(-1), ExactDateInfo.BeforeChrist(1, 1, 1, 0) }); yield return(new object[] { Duration.Zero.AddYears(-5).AddMonths(4), ExactDateInfo.BeforeChrist(5, 5, 1, 0) }); yield return(new object[] { Duration.Zero.AddYears(-5).AddDays(12), ExactDateInfo.BeforeChrist(5, 1, 13, 0) }); yield return(new object[] { Duration.Zero.AddYears(-5).AddHours(21), ExactDateInfo.BeforeChrist(5, 1, 1, 21) }); yield return(new object[] { Duration.Zero .AddYears(-5000000) .AddMonths(12 - 1) .AddDays(31 - 1) .AddHours(23), ExactDateInfo.BeforeChrist(5000000, 12, 31, 23) }); yield return(new object[] { Duration.Zero .AddYears(1979) .AddMonths(1) .AddDays(29) .AddHours(1), ExactDateInfo.AnnoDomini(1980, 3, 1, 1) }); }
public void Compare_dates_with_different_years_and_months() { ExactDateInfo.AnnoDomini(100, 2, 1, 0).ShouldBeLessThan(ExactDateInfo.AnnoDomini(100, 3, 1, 0)); ExactDateInfo.BeforeChrist(200, 2, 1, 0).ShouldBeLessThan(ExactDateInfo.BeforeChrist(200, 3, 1, 0)); }
public void Compare_dates_in_different_eras() { ExactDateInfo.BeforeChrist(100, 1, 1, 0).ShouldBeLessThan(ExactDateInfo.AnnoDomini(100, 1, 1, 0)); ExactDateInfo.BeforeChrist(200, 1, 1, 0).ShouldBeLessThan(ExactDateInfo.AnnoDomini(100, 1, 1, 0)); }