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 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); }