public async Task CancelExchangeTest() { IMongoDatabase database = _mongoFixture.MongoClient.GetDatabase("StudentsDB"); StudentService studentSrv = new StudentService(database); BlockChangesService blockChangeService = new BlockChangesService(database); var options = GetProxyOptions(); var schoolScheduleProxy = new SchoolScheduleProxy(options); var schoolCourseProxy = new SchoolCourseProxy(options); CourseService courseService = new CourseService(_loggerMockCourse.Object, database, schoolScheduleProxy, schoolCourseProxy); Course course = await CreateAndAddCourse("Programovanie", "11111", courseService); Block block1 = CreateBlock(BlockType.Laboratory, Day.Monday, 2, 7, course.Id); Block block2 = CreateBlock(BlockType.Laboratory, Day.Wednesday, 2, 10, course.Id); Block block3 = CreateBlock(BlockType.Laboratory, Day.Wednesday, 2, 8, course.Id); Student student = new Student(); await studentSrv.AddAsync(student); BlockChangeRequest blockToChange = CreateBlockChangeRequest(block2, block1, student.Id); BlockChangeRequest blockToChange1 = CreateBlockChangeRequest(block3, block1, student.Id); (await blockChangeService.AddAndFindMatch(blockToChange)).Should().Be((null, null)); (await blockChangeService.AddAndFindMatch(blockToChange1)).Should().Be((null, null)); blockChangeService.FindWaitingStudentRequests(student.Id).Result.Count.Should().Be(2); (await blockChangeService.CancelExchangeRequest(blockToChange1)).Should().Be(true); blockChangeService.FindWaitingStudentRequests(student.Id).Result.Count.Should().Be(1); }
public async Task AssingTimetableToStudent() { var options = GetProxyOptions(); var schoolScheduleProxy = new SchoolScheduleProxy(options); var schoolCourseProxy = new SchoolCourseProxy(options); CourseService serviceCourse = new(_loggerMockCourse.Object, _database, schoolScheduleProxy, schoolCourseProxy); var timetable = await schoolScheduleProxy.GetByPersonalNumber("559841"); Student student = new() { PersonalNumber = "559841", Timetable = await ConverterApiToDomain.ConvertTimetableForPersonalNumberAsync(timetable, serviceCourse) }; var newBlock = new Block(); var countShouldBe = student.Timetable.AllBlocks.Count; student.Timetable.AddNewBlock(newBlock); student.Timetable.AllBlocks.Count().Should().Be(countShouldBe + 1); var newBlockSt = new Block(); countShouldBe = student.Timetable.AllBlocks.Count; student.Timetable.AddNewBlock(newBlockSt); student.Timetable.AllBlocks.Count().Should().Be(countShouldBe + 1); }
public async Task AddStudentTest() { var options = GetProxyOptions(); var schoolScheduleProxy = new SchoolScheduleProxy(options); var schoolCourseProxy = new SchoolCourseProxy(options); CourseService serviceCourse = new(_loggerMockCourse.Object, _database, schoolScheduleProxy, schoolCourseProxy); StudentService stSer = new(_database); var timetable = await schoolScheduleProxy.GetByPersonalNumber("559841"); Student st = new() { PersonalNumber = "559841", Timetable = await ConverterApiToDomain.ConvertTimetableForPersonalNumberAsync(timetable, serviceCourse) }; Course cr = new() { CourseName = "DISS", Id = Guid.NewGuid() }; Block bl = new() { BlockType = BlockType.Lecture, CourseId = cr.Id, StartHour = 16, Duration = 2, Day = Day.Thursday }; st.Timetable.AddNewBlock(bl); await stSer.AddAsync(st); st = await stSer.FindByIdAsync(st.Id); st.Id.Should().NotBeEmpty(); st.PersonalNumber.Should().Be("559841"); st.Timetable.AllBlocks.Last().Day.Should().Be(Day.Thursday); st.Timetable.AllBlocks.Last().Duration.Should().Be(2); st.Timetable.AllBlocks.Last().StartHour.Should().Be(16); st.Timetable.AllBlocks.Last().BlockType.Should().Be(BlockType.Lecture); } [Fact]
public async Task ExchangeRequests_ExchangingRequests_ExchangedRequests() { IMongoDatabase database = _mongoFixture.MongoClient.GetDatabase("StudentsDB"); StudentService studentSrv = new StudentService(database); BlockChangesService blockChangeService = new BlockChangesService(database); var options = GetProxyOptions(); var schoolScheduleProxy = new SchoolScheduleProxy(options); var schoolCourseProxy = new SchoolCourseProxy(options); CourseService courseService = new CourseService(_loggerMockCourse.Object, database, schoolScheduleProxy, schoolCourseProxy); Course course = await CreateAndAddCourse("Programovanie", "11111", courseService); Course course2 = await CreateAndAddCourse("Programovanie", "11111", courseService); Block block1 = CreateBlock(BlockType.Laboratory, Day.Monday, 2, 7, course.Id); Block block2 = CreateBlock(BlockType.Laboratory, Day.Wednesday, 2, 10, course.Id); Block block3 = CreateBlock(BlockType.Laboratory, Day.Tuesday, 2, 15, course.Id); Block block4 = CreateBlock(BlockType.Laboratory, Day.Friday, 2, 18, course2.Id); Student student1 = new Student(); Student student2 = new Student(); Student student3 = new Student(); await studentSrv.AddAsync(student1); await studentSrv.AddAsync(student2); await studentSrv.AddAsync(student3); BlockChangeRequest blockToChange1 = CreateBlockChangeRequest(block1, block2, student1.Id); BlockChangeRequest blockToChange2 = CreateBlockChangeRequest(block1, block3, student1.Id); BlockChangeRequest blockToChange3 = CreateBlockChangeRequest(block1, block2, student2.Id); BlockChangeRequest blockToChange4 = CreateBlockChangeRequest(block1, block3, student2.Id); BlockChangeRequest blockToChange5 = CreateBlockChangeRequest(block4, block2, student3.Id); BlockChangeRequest blockToChange = CreateBlockChangeRequest(block2, block1, student3.Id); ValueTuple <BlockChangeRequest, BlockChangeRequest> result = new ValueTuple <BlockChangeRequest, BlockChangeRequest>(); result = (null, null); (await blockChangeService.AddAndFindMatch(blockToChange1)).Should().Equals(result); (await blockChangeService.AddAndFindMatch(blockToChange2)).Should().Equals(result); (await blockChangeService.AddAndFindMatch(blockToChange3)).Should().Equals(result); (await blockChangeService.AddAndFindMatch(blockToChange4)).Should().Equals(result); (await blockChangeService.AddAndFindMatch(blockToChange5)).Should().Equals(result); result = (blockToChange, blockToChange1); (await blockChangeService.AddAndFindMatch(blockToChange)).Should().Equals(result); blockChangeService.FindAllStudentRequests(student1.Id).Result.Count.Should().Be(1); blockChangeService.FindAllStudentRequests(student2.Id).Result.Count.Should().Be(2); blockChangeService.FindAllStudentRequests(student3.Id).Result.Count.Should().Be(2); blockChangeService.FindWaitingStudentRequests(student1.Id).Result.Count.Should().Be(0); blockChangeService.FindWaitingStudentRequests(student2.Id).Result.Count.Should().Be(2); blockChangeService.FindWaitingStudentRequests(student3.Id).Result.Count.Should().Be(1); BlockChangeRequest blockToChange6 = CreateBlockChangeRequest(block3, block2, student1.Id); (await blockChangeService.AddAndFindMatch(blockToChange6)).Should().Be((null, null)); blockChangeService.FindWaitingStudentRequests(student1.Id).Result.Count.Should().Be(1); blockChangeService.FindWaitingStudentRequests(student2.Id).Result.Count.Should().Be(2); blockChangeService.FindWaitingStudentRequests(student3.Id).Result.Count.Should().Be(1); }