public void CannotAddSameSchedulesTwice() { var service = new CifService("X12345", Substitute.For <ILogger>()); var permanent = TestSchedules.CreateSchedule(indicator: StpIndicator.Permanent, calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Monday)); service.Add(permanent); var ex = Assert.Throws <ArgumentException>(() => service.Add(permanent)); Assert.StartsWith("Schedule already added", ex.Message); }
public void CanAddSchedulesWithSameStpIndicator() { var service = new CifService("X12345", Substitute.For <ILogger>()); var permanent = TestSchedules.CreateSchedule(indicator: StpIndicator.Permanent, calendar: TestSchedules.EverydayAugust2019); var permanent2 = TestSchedules.CreateSchedule(indicator: StpIndicator.Permanent, calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Monday)); service.Add(permanent); service.Add(permanent2); var schedules = service.GetSchedules(); Assert.Equal(2, schedules.Count); }
public void CanAddSchedulesWithDifferentStpIndicator() { var service = new CifService("X12345", Substitute.For <ILogger>()); var permanent = TestSchedules.CreateSchedule(indicator: StpIndicator.Permanent, calendar: TestSchedules.EverydayAugust2019); var overlay = TestSchedules.CreateSchedule(indicator: StpIndicator.Override, calendar: TestSchedules.EverydayAugust2019); service.Add(permanent); service.Add(overlay); var schedules = service.GetSchedules(); Assert.Equal(2, schedules.Count); }
public void TryGetScheduleMultipleSchedulesDifferentCalendar(ICalendar calendar, bool expectedFound, bool isFirst) { var service = new CifService("X12345", Substitute.For <ILogger>()); var permanent = TestSchedules.CreateSchedule(indicator: StpIndicator.Permanent, calendar: TestSchedules.EverydayAugust2019); var permanent2 = TestSchedules.CreateSchedule(indicator: StpIndicator.Permanent, calendar: TestSchedules.CreateAugust2019Calendar(DaysFlag.Monday)); service.Add(permanent); service.Add(permanent2); Assert.Equal(expectedFound, service.TryGetSchedule((StpIndicator.Permanent, calendar), out var schedule)); if (expectedFound) { var expected = isFirst ? permanent : permanent2; Assert.Equal(expected, schedule); } }
public void TryGetScheduleMultipleSchedulesDifferentStp(StpIndicator indicator, bool expectedFound, bool isPermanent) { var service = new CifService("X12345", Substitute.For <ILogger>()); var permanent = TestSchedules.CreateSchedule(indicator: StpIndicator.Permanent, calendar: TestSchedules.EverydayAugust2019); var overlay = TestSchedules.CreateSchedule(indicator: StpIndicator.Override, calendar: TestSchedules.EverydayAugust2019); service.Add(permanent); service.Add(overlay); Assert.Equal(expectedFound, service.TryGetSchedule((indicator, TestSchedules.EverydayAugust2019), out var schedule)); if (expectedFound) { var expected = isPermanent ? permanent : overlay; Assert.Equal(expected, schedule); } }