コード例 #1
0
        public async Task AddNewDateToWorkerSchedule()
        {
            var anotherDate = DateHelper.GetFirstDayOfMonth(currentDate).AddDays(5);

            if (currentDate == anotherDate)
            {
                anotherDate = currentDate.AddDays(5);
            }

            var newRecord = CreateRecord(new TimePeriod(TimeSpan.FromHours(4), TimeSpan.FromHours(6)));
            await workerScheduleRepository.WriteAsync(shopId, WorkerCalendarDayBuilder <T> .Create(workerId, anotherDate)
                                                      .AddRecord(newRecord)
                                                      .Build());

            var shopCalendarMonth = await workerScheduleRepository.ReadShopCalendarMonthAsync(shopId, currentDate);

            shopCalendarMonth.Should().BeEquivalentTo(
                ShopCalendarMonthBuilder <T> .Create(shopId, currentDate)
                .AddShopDay(currentDate,
                            shopBuilder => shopBuilder.AddWorkerDay(workerId, workerBuilder => workerBuilder.AddRecord(defaultRecord)))
                .AddShopDay(currentDate.AddDays(5),
                            shopBuilder => shopBuilder.AddWorkerDay(workerId, workerBuilder => workerBuilder.AddRecord(newRecord)))
                .Build());

            var workerSchedule = await workerScheduleRepository.ReadWorkerCalendarDayAsync(shopId, anotherDate, workerId);

            workerSchedule.Should().BeEquivalentTo(WorkerCalendarDayBuilder <T> .Create(workerId, anotherDate)
                                                   .AddRecord(newRecord)
                                                   .Build());
        }
コード例 #2
0
        public async Task UpdateEmptyScheduleTest()
        {
            var shopCalendarMonth = await workerScheduleRepository.ReadShopCalendarMonthAsync(shopId, currentDate);

            shopCalendarMonth.Should().BeEquivalentTo(ShopCalendarMonthBuilder <T>
                                                      .Create(shopId, currentDate)
                                                      .AddShopDay(currentDate,
                                                                  shopBuilder => shopBuilder.AddWorkerDay(workerId,
                                                                                                          workerBuilder => workerBuilder.AddRecord(defaultRecord)))
                                                      .Build());

            var shopCalendarDay = await workerScheduleRepository.ReadShopCalendarDayAsync(shopId, currentDate);

            shopCalendarDay.Should().BeEquivalentTo(ShopCalendarDayBuilder <T> .Create(shopId, currentDate)
                                                    .AddWorkerDay(workerId, builder => builder.AddRecord(defaultRecord))
                                                    .Build());

            var workerSchedule = await workerScheduleRepository.ReadWorkerCalendarDayAsync(shopId, currentDate, workerId);

            workerSchedule.Should().BeEquivalentTo(WorkerCalendarDayBuilder <T> .Create(workerId, currentDate)
                                                   .AddRecord(defaultRecord)
                                                   .Build());
        }