public void 排除時間_結束時間相同() { var sourcePeriod = new DurationDto(new DateTime(2020, 2, 3, 8, 0, 0), new DateTime(2020, 2, 3, 17, 0, 0)); var exceptPeriods = new[] { new DurationDto(new DateTime(2020, 2, 3, 8, 5, 0), new DateTime(2020, 2, 3, 9, 5, 0)), new DurationDto(new DateTime(2020, 2, 3, 10, 10, 0), new DateTime(2020, 2, 3, 11, 0, 0)), new DurationDto(new DateTime(2020, 2, 3, 14, 0, 0), new DateTime(2020, 2, 3, 17, 0, 0)), }; var actual = sourcePeriod.Except(exceptPeriods).ToArray(); var expected = new[] { new DurationDto(new DateTime(2020, 2, 3, 8, 0, 0), new DateTime(2020, 2, 3, 8, 5, 0)), new DurationDto(new DateTime(2020, 2, 3, 9, 5, 0), new DateTime(2020, 2, 3, 10, 10, 0)), new DurationDto(new DateTime(2020, 2, 3, 11, 0, 0), new DateTime(2020, 2, 3, 14, 0, 0)), }; actual.Should().BeEquivalentTo(expected); }
public void 一個排除時間_起始結束過晚() { var sourcePeriod = new DurationDto(new DateTime(2020, 2, 3, 9, 0, 0), new DateTime(2020, 2, 3, 10, 0, 0)); var exceptPeriods = new[] { new DurationDto(new DateTime(2020, 2, 3, 11, 0, 0), new DateTime(2020, 2, 3, 11, 30, 0)), }; var actual = sourcePeriod.Except(exceptPeriods).ToArray(); var expected = new[] { new DurationDto(new DateTime(2020, 2, 3, 9, 0, 0), new DateTime(2020, 2, 3, 10, 0, 0)) }; actual.Should().BeEquivalentTo(expected); }