public void ShouldIncludesNodaTime() { var batchdr = new BatchDateRange(DateTimeExtensions.CreateNodaTime(2019, 2, 10, 0, 0, 0), DateTimeExtensions.CreateNodaTime(2019, 2, 16, 23, 59, 59)); // start bool included = batchdr.Includes(DateTimeExtensions.CreateNodaTime(2019, 2, 10, 0, 0, 0)); Assert.True(included); // > start && < end bool included1 = batchdr.Includes(DateTimeExtensions.CreateNodaTime(2019, 2, 13, 23, 22, 22)); Assert.True(included1); // end bool included2 = batchdr.Includes(DateTimeExtensions.CreateNodaTime(2019, 2, 16, 23, 59, 59)); Assert.True(included2); // < start bool included3 = batchdr.Includes(DateTimeExtensions.CreateNodaTime(1, 2, 13, 23, 22, 22)); Assert.False(included3); // > end bool included4 = batchdr.Includes(DateTimeExtensions.CreateNodaTime(2019, 2, 17, 0, 0, 0)); Assert.False(included4); }
public void ShouldIncludesNodaTimeRange() { var batchdr = new BatchDateRange(DateTimeExtensions.CreateNodaTime(2019, 2, 10, 0, 0, 0), DateTimeExtensions.CreateNodaTime(2019, 2, 16, 23, 59, 59)); // start == batchdr.Start && end == batchdr.Start var dr1 = new BatchDateRange(DateTimeExtensions.CreateNodaTime(2019, 2, 10, 0, 0, 0), DateTimeExtensions.CreateNodaTime(2019, 2, 10, 0, 0, 0)); Assert.True(batchdr.Includes(dr1)); // start == batchdr.Start && end == batchdr.End var dr2 = new BatchDateRange(DateTimeExtensions.CreateNodaTime(2019, 2, 10, 0, 0, 0), DateTimeExtensions.CreateNodaTime(2019, 2, 16, 23, 59, 59)); Assert.True(batchdr.Includes(dr2)); // start == batchdr.End && end == batchdr.End var dr3 = new BatchDateRange(DateTimeExtensions.CreateNodaTime(2019, 2, 16, 23, 59, 59), DateTimeExtensions.CreateNodaTime(2019, 2, 16, 23, 59, 59)); Assert.True(batchdr.Includes(dr3)); // start > batchdr.Start && end < batchdr.End var dr4 = new BatchDateRange(DateTimeExtensions.CreateNodaTime(2019, 2, 10, 1, 59, 59), DateTimeExtensions.CreateNodaTime(2019, 2, 15, 23, 59, 59)); Assert.True(batchdr.Includes(dr4)); // start > batchdr.Start && end > batchdr.End var dr5 = new BatchDateRange(DateTimeExtensions.CreateNodaTime(2019, 2, 10, 1, 59, 59), DateTimeExtensions.CreateNodaTime(2019, 2, 17, 23, 59, 59)); Assert.False(batchdr.Includes(dr5)); // start < batchdr.Start && end < batchdr.End var dr6 = new BatchDateRange(DateTimeExtensions.CreateNodaTime(2019, 2, 9, 1, 59, 59), DateTimeExtensions.CreateNodaTime(2019, 2, 15, 23, 59, 59)); Assert.False(batchdr.Includes(dr6)); // start < batchdr.Start && end > batchdr.End var dr7 = new BatchDateRange(DateTimeExtensions.CreateNodaTime(2019, 2, 9, 1, 59, 59), DateTimeExtensions.CreateNodaTime(2019, 2, 17, 23, 59, 59)); Assert.False(batchdr.Includes(dr7)); }