private List <DateAndTimeOnly> CreateDatabaseData(IDocumentStore store) { TimeOnly timeOnly = new TimeOnly(0, 0, 0, 234); DateOnly dateOnly; var database = Enumerable.Range(0, 1000) .Select(i => new DateAndTimeOnly() { TimeOnly = timeOnly.AddMinutes(i), DateOnly = dateOnly.AddDays(i), DateTime = DateTime.Now }).ToList(); { using var bulkInsert = store.BulkInsert(); database.ForEach(i => bulkInsert.Store(i)); } return(database); }
public static void AddTest() { TimeOnly to = new TimeOnly(1, 10, 20, 900); to = to.Add(new TimeSpan(1)); Assert.Equal(TimeSpan.NanosecondsPerTick, to.Nanosecond); to = to.Add(new TimeSpan(TimeSpan.TicksPerMicrosecond)); Assert.Equal(1, to.Microsecond); to = to.Add(new TimeSpan(TimeSpan.TicksPerMillisecond)); Assert.Equal(901, to.Millisecond); to = to.Add(new TimeSpan(TimeSpan.TicksPerSecond)); Assert.Equal(21, to.Second); to = to.Add(new TimeSpan(TimeSpan.TicksPerMinute)); Assert.Equal(11, to.Minute); to = to.Add(new TimeSpan(TimeSpan.TicksPerHour)); Assert.Equal(2, to.Hour); to = TimeOnly.MinValue.Add(new TimeSpan(-1), out int wrappedDays); Assert.Equal(23, to.Hour); Assert.Equal(59, to.Minute); Assert.Equal(59, to.Second); Assert.Equal(999, to.Millisecond); Assert.Equal(-1, wrappedDays); to = TimeOnly.MinValue.Add(new TimeSpan(48, 0, 0), out wrappedDays); Assert.Equal(0, to.Hour); Assert.Equal(0, to.Minute); Assert.Equal(0, to.Second); Assert.Equal(0, to.Millisecond); Assert.Equal(2, wrappedDays); to = to.Add(new TimeSpan(1, 0, 0), out wrappedDays); Assert.Equal(0, wrappedDays); to = TimeOnly.MinValue.AddHours(1.5); Assert.Equal(1, to.Hour); Assert.Equal(30, to.Minute); Assert.Equal(0, to.Second); Assert.Equal(0, to.Millisecond); Assert.Equal(0, to.Microsecond); Assert.Equal(0, to.Nanosecond); to = to.AddHours(1.5, out wrappedDays); Assert.Equal(3, to.Hour); Assert.Equal(0, to.Minute); Assert.Equal(0, to.Second); Assert.Equal(0, to.Microsecond); Assert.Equal(0, to.Nanosecond); Assert.Equal(0, wrappedDays); to = to.AddHours(-28, out wrappedDays); Assert.Equal(23, to.Hour); Assert.Equal(0, to.Minute); Assert.Equal(-2, wrappedDays); to = to.AddHours(1, out wrappedDays); Assert.Equal(1, wrappedDays); Assert.Equal(0, to.Hour); Assert.Equal(0, to.Minute); to = to.AddMinutes(190.5); Assert.Equal(3, to.Hour); Assert.Equal(10, to.Minute); Assert.Equal(30, to.Second); to = to.AddMinutes(-4 * 60, out wrappedDays); Assert.Equal(23, to.Hour); Assert.Equal(10, to.Minute); Assert.Equal(30, to.Second); Assert.Equal(-1, wrappedDays); to = to.AddMinutes(60.5, out wrappedDays); Assert.Equal(0, to.Hour); Assert.Equal(11, to.Minute); Assert.Equal(0, to.Second); Assert.Equal(1, wrappedDays); }