public async Task ShouldGetTimeslotItem()
        {
            var instructorDto = await CreateInstructorAsync();

            var courseDto = await CreateCourseAsync();

            var locationDto = await CreateLocationWithInstructorAsync(instructorDto);

            var classroomDto = await CreateClassroomAsync(locationDto);

            var dailyScheduleDto = await CreateDailyScheduleAsync(classroomDto);

            var courseClassDto = await CreateCourseClassAsync(courseDto, locationDto);

            var subjectDto = await CreateSubjectAsync(instructorDto);

            var classSubjectDto = await CreateClassSubjectAsync(subjectDto, courseClassDto);

            var command = new CreateTimeslotItemCommand()
            {
                Disabled        = false,
                Duration        = new TimeSpan(1, 0, 0),
                StartTime       = new TimeSpan(0, 22, 0),
                DailyScheduleId = dailyScheduleDto.Id,
                ClassSubjectId  = classSubjectDto.Id,
            };
            var timeslotDto = await SendAsync(command);

            GetTimeslotItemQuery query = new GetTimeslotItemQuery()
            {
                Id = timeslotDto.Id
            };
            GetTimeslotItemDto dto = await SendAsync(query);

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

            dto.ShouldNotBeNull();
            dto.Id.ShouldBe(created.Id);
            dto.DailyScheduleId.ShouldBe(created.DailyScheduleId);
            dto.StartTime.ShouldBe(created.StartTime);
            dto.Duration.ShouldBe(created.Duration);
            dto.Disabled.ShouldBe(created.Disabled);
        }
Example #2
0
        public async Task ShouldNotCreateTimeslotWhenRoomTimeSlotAlreadyTaken()
        {
            var instructorDto = await CreateInstructorAsync();

            var courseDto = await CreateCourseAsync();

            var locationDto = await CreateLocationWithInstructorAsync(instructorDto);

            var classroomDto = await CreateClassroomAsync(locationDto);

            var dailyScheduleDto = await CreateDailyScheduleAsync(classroomDto);

            var courseClassDto = await CreateCourseClassAsync(courseDto, locationDto);

            var subjectDto = await CreateSubjectAsync(instructorDto);

            var classSubjectDto = await CreateClassSubjectAsync(subjectDto, courseClassDto);

            var command1st = new CreateTimeslotItemCommand
            {
                Disabled        = false,
                DailyScheduleId = dailyScheduleDto.Id,
                ClassSubjectId  = classSubjectDto.Id,
                Duration        = new TimeSpan(0, 1, 0),
                StartTime       = new TimeSpan(0, 20, 0),
            };
            var timeslotDto1st = await SendAsync(command1st);

            var command2nd = new CreateTimeslotItemCommand
            {
                Disabled        = false,
                DailyScheduleId = dailyScheduleDto.Id,
                ClassSubjectId  = classSubjectDto.Id,
                Duration        = new TimeSpan(0, 1, 0),
                StartTime       = new TimeSpan(0, 20, 0),
            };

            await SendWithValidationAsync(command2nd, new CreateTimeslotItemCommandValidator()).ShouldThrowAsync <EntityAlreadyExistException>();
        }
Example #3
0
        public async Task ShouldCreateTimeslot()
        {
            var instructorDto = await CreateInstructorAsync();

            var courseDto = await CreateCourseAsync();

            var locationDto = await CreateLocationWithInstructorAsync(instructorDto);

            var courseClassDto = await CreateCourseClassAsync(courseDto, locationDto);

            var subjectDto = await CreateSubjectAsync(instructorDto);

            var classSubjectDto = await CreateClassSubjectAsync(subjectDto, courseClassDto);

            var classroomDto = await CreateClassroomAsync(locationDto);

            var dailyScheduleDto = await CreateDailyScheduleAsync(classroomDto);

            var command = new CreateTimeslotItemCommand
            {
                Disabled        = false,
                DailyScheduleId = dailyScheduleDto.Id,
                ClassSubjectId  = classSubjectDto.Id,
                Duration        = new TimeSpan(0, 1, 0),
                StartTime       = new TimeSpan(0, 20, 0),
            };
            var timeslotDto = await SendWithValidationAsync(command, new CreateTimeslotItemCommandValidator());

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

            created.ShouldNotBeNull();
            created.DailyScheduleId.ShouldBe(command.DailyScheduleId);
            created.StartTime.ShouldBe(command.StartTime);
            created.Disabled.ShouldBe(command.Disabled);
            created.Duration.ShouldBe(command.Duration);
        }