예제 #1
0
        public async Task GetChangesWithOneScheduleWhichAlreadyExistsAndDidNotChangeReturnsEmptyListTest(string email)
        {
            // arrange
            var ct    = new CancellationToken(false);
            var weeks = new Dictionary <int, WeekItem>
            {
                { 0, new WeekItem(6, 2015) },
            };

            IFlexKidsClient     flexKidsClient     = A.Fake <IFlexKidsClient>();
            IKseParser          parser             = A.Fake <IKseParser>();
            IScheduleRepository scheduleRepository = A.Dummy <IScheduleRepository>();
            var sut = new Scheduler(flexKidsClient, parser, scheduleRepository);

            _ = A.CallTo(() => parser.GetIndexContent(A <string> ._))
                .Returns(new IndexContent
            {
                Email = email,
                Weeks = weeks,
            });
            _ = A.CallTo(() => flexKidsClient.GetSchedulePage(0, ct)).Returns("GetSchedulePage0");
            _ = A.CallTo(() => scheduleRepository.Get(2015, 6))
                .Returns(new WeekSchedule {
            });

            // act
            IEnumerable <ScheduleDiff> result = await sut.ProcessAsync(ct);

            // assert
            Assert.Empty(result);
            _ = A.CallTo(() => flexKidsClient.GetAvailableSchedulesPage(ct)).MustHaveHappenedOnceExactly();
            _ = A.CallTo(() => parser.GetIndexContent(A <string> ._)).MustHaveHappenedOnceExactly();
            _ = A.CallTo(() => flexKidsClient.GetSchedulePage(0, ct)).MustHaveHappenedOnceExactly();
            _ = A.CallTo(() => scheduleRepository.Get(2015, 6)).MustHaveHappenedOnceExactly();
        }
예제 #2
0
 public Scheduler(IFlexKidsConnection flexKidsConnection, IKseParser parser, IScheduleRepository scheduleRepository, IHash hash)
 {
     this.flexKidsConnection = flexKidsConnection;
     this.hash   = hash;
     this.parser = parser;
     repo        = scheduleRepository;
 }
예제 #3
0
        public async Task GetChangesWithNoChangesReturnsEmptyListTest(string email)
        {
            // arrange
            var             ct             = new CancellationToken(false);
            IFlexKidsClient flexKidsClient = A.Fake <IFlexKidsClient>();
            IKseParser      parser         = A.Fake <IKseParser>();

            _ = A.CallTo(() => parser.GetIndexContent(A <string> ._))
                .Returns(new IndexContent
            {
                Email = email,
                Weeks = new Dictionary <int, WeekItem>(),
            });

            IScheduleRepository scheduleRepository = A.Dummy <IScheduleRepository>();
            var sut = new Scheduler(flexKidsClient, parser, scheduleRepository);

            // act
            IEnumerable <ScheduleDiff> result = await sut.ProcessAsync(ct);

            // assert
            Assert.Empty(result);
            _ = A.CallTo(() => flexKidsClient.GetAvailableSchedulesPage(ct)).MustHaveHappenedOnceExactly();
            _ = A.CallTo(() => parser.GetIndexContent(A <string> ._)).MustHaveHappenedOnceExactly();

            A.CallTo(() => flexKidsClient.GetSchedulePage(A <int> ._, ct)).MustNotHaveHappened();
            A.CallTo(scheduleRepository).MustNotHaveHappened();
        }
예제 #4
0
 public Scheduler(IFlexKidsClient flexKidsClient, IKseParser parser, IScheduleRepository scheduleRepository)
 {
     _flexKidsClient = flexKidsClient ?? throw new ArgumentNullException(nameof(flexKidsClient));
     _parser         = parser ?? throw new ArgumentNullException(nameof(parser));
     _repo           = scheduleRepository ?? throw new ArgumentNullException(nameof(scheduleRepository));
 }