public void RemoveAtTest() { SchoolDay schoolDay = new SchoolDay(); // first int count = schoolDay.Count; DateTime end = schoolDay.End; ITimePeriod removeItem = schoolDay[0]; TimeSpan duration = schoolDay.Duration; schoolDay.RemoveAt(0); Assert.Equal <int>(schoolDay.Count, count - 1); Assert.NotEqual(schoolDay[0], removeItem); Assert.Equal <DateTime>(schoolDay.End, end); Assert.Equal <TimeSpan>(schoolDay.Duration, duration.Subtract(removeItem.Duration)); // inside count = schoolDay.Count; duration = schoolDay.Duration; DateTime start = schoolDay.Start; ITimePeriod first = schoolDay.First; ITimePeriod last = schoolDay.Last; removeItem = schoolDay[1]; schoolDay.RemoveAt(1); Assert.Equal <int>(schoolDay.Count, count - 1); Assert.NotEqual(schoolDay[1], removeItem); Assert.Equal(schoolDay.First, first); Assert.Equal <DateTime>(schoolDay.Start, start); Assert.Equal(schoolDay.Last, last); Assert.Equal <TimeSpan>(schoolDay.Duration, duration.Subtract(removeItem.Duration)); // last count = schoolDay.Count; start = schoolDay.Start; duration = schoolDay.Duration; removeItem = schoolDay[schoolDay.Count - 1]; schoolDay.RemoveAt(schoolDay.Count - 1); Assert.Equal <int>(schoolDay.Count, count - 1); Assert.NotEqual(schoolDay[schoolDay.Count - 1], removeItem); Assert.Equal <DateTime>(schoolDay.Start, start); Assert.Equal <TimeSpan>(schoolDay.Duration, duration.Subtract(removeItem.Duration)); } // RemoveAtTest
public void IsSamePeriodTest() { SchoolDay schoolDay = new SchoolDay(); TimeRange manualRange = new TimeRange(schoolDay.Start, schoolDay.End); Assert.True(schoolDay.IsSamePeriod(schoolDay)); Assert.True(schoolDay.IsSamePeriod(manualRange)); Assert.True(manualRange.IsSamePeriod(schoolDay)); Assert.False(schoolDay.IsSamePeriod(TimeBlock.Anytime)); Assert.False(manualRange.IsSamePeriod(TimeBlock.Anytime)); schoolDay.RemoveAt(0); Assert.False(schoolDay.IsSamePeriod(manualRange)); Assert.False(manualRange.IsSamePeriod(schoolDay)); } // IsSamePeriodTest