public async Task ShouldCreateWeeklySchedule()
        {
            var locationDto = await SendAsync(new CreateLocationItemCommand
            {
                Name      = "location1",
                IsEnabled = true
            });

            var classroomDto = await SendAsync(new CreateClassroomFromLocationCommand
            {
                IsEnabled  = true,
                Name       = "Classroom1",
                Capacity   = 40,
                LocationId = locationDto.Id
            });

            var scheduleDate = DateTime.UtcNow.Date;
            var command      = new CreateDailyScheduleItemCommand()
            {
                DayOfWeek    = DayOfWeek.Monday,
                Disabled     = false,
                WeekNumber   = 3,
                DateSchedule = scheduleDate,
                ClassroomId  = classroomDto.Id,
            };
            var dto = await SendWithValidationAsync(command, new CreateDailyScheduleItemCommandValidator());

            var created = await ExecuteDbContextAsync(db =>
                                                      db.DailySchedules.Where(c => c.Id.Equals(dto.Id)).SingleOrDefaultAsync());

            created.ShouldNotBeNull();
            created.WeekNumber.ShouldBe(command.WeekNumber);
            created.ClassroomId.ShouldBe(command.ClassroomId);
            created.DateSchedule.ShouldBe(command.DateSchedule);
        }
Пример #2
0
        private async Task <CreateDailyScheduleItemDto> CreateDailyScheduleAsync(CreateClassroomFromLocationDto classroomDto)
        {
            var scheduleDate = DateTime.UtcNow.Date;
            var command      = new CreateDailyScheduleItemCommand()
            {
                DayOfWeek    = DayOfWeek.Monday,
                Disabled     = false,
                WeekNumber   = 3,
                DateSchedule = scheduleDate,
                ClassroomId  = classroomDto.Id,
            };
            var dto = await SendAsync(command);

            return(dto);
        }
        public async Task ShouldGetWeeklyScheduleList()
        {
            var locationDto = await SendAsync(new CreateLocationItemCommand
            {
                Name      = "location1",
                IsEnabled = true
            });

            var classroomDto = await SendAsync(new CreateClassroomFromLocationCommand
            {
                IsEnabled  = true,
                Name       = "Classroom1",
                Capacity   = 40,
                LocationId = locationDto.Id
            });

            var scheduleDate = DateTime.UtcNow.Date;
            var command      = new CreateDailyScheduleItemCommand()
            {
                DayOfWeek    = DayOfWeek.Monday,
                Disabled     = false,
                WeekNumber   = 3,
                DateSchedule = scheduleDate,
                ClassroomId  = classroomDto.Id,
            };
            var dailyScheduleDto = await SendAsync(command);


            var query = new GetDailyScheduleListQuery()
            {
            };
            var dto = await SendAsync(query);

            var created = await ExecuteDbContextAsync(db =>
                                                      db.DailySchedules.Where(c => c.Id.Equals(dailyScheduleDto.Id)).SingleOrDefaultAsync());

            dto.ShouldNotBeNull();
            dto.Count.ShouldBeGreaterThanOrEqualTo(1);
            dto.Data.ShouldContain(d => d.Id.Equals(created.Id));
        }