Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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]