Exemple #1
0
        public async Task EditGrade_WithExistentId_ShouldSuccessfullyEditGrade()
        {
            string errorMessagePrefix = "GradeService EditGradeAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.gradeService = new GradeService(context);

            var testId = context.Grades.First().Id;

            var editGrade = new GradeServiceModel
            {
                Id          = testId,
                GradeValue  = "3",
                Term        = Term.Втори,
                IsTermGrade = false,
            };

            var actualResult = await this.gradeService.EditGradeAsync(editGrade);

            Assert.True(actualResult, errorMessagePrefix);

            var editedGrade = context.Grades.First();

            Assert.True(editedGrade.GradeValue == editGrade.GradeValue, errorMessagePrefix + " " + "GradeValue is not set properly.");
            Assert.True(editedGrade.Term == editGrade.Term, errorMessagePrefix + " " + "Term is not set properly.");
            Assert.True(editedGrade.IsTermGrade == editGrade.IsTermGrade, errorMessagePrefix + " " + "IsTermGrade is not set properly.");
        }
        public async Task CreateAbsence_WithCorrectData_ShouldSuccessfullyCreateOrder()
        {
            string errorMessagePrefix = "AbsenceService CreateAbsenceAsync() method does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.absenceService = new AbsenceService(context);

            var student = new Student
            {
                Id       = "test",
                FullName = "Test",
                Absences = new List <Absence>(),
            };

            await context.Students.AddAsync(student);

            await context.SaveChangesAsync();

            AbsenceServiceModel testAbsence = new AbsenceServiceModel
            {
                StudentId = student.Id,
                Student   = student.To <StudentServiceModel>(),
            };

            bool actualResult = await this.absenceService.CreateAbsenceAsync(testAbsence);

            var updatedStudent        = context.Students.First();
            var expectedAbsencesCount = 1;

            Assert.True(actualResult, errorMessagePrefix);
            Assert.Equal(updatedStudent.Absences.Count, expectedAbsencesCount);
        }
Exemple #3
0
        public async Task CreateGrade_WithAnotherTermGrade_ShouldReturnFalse()
        {
            string errorMessagePrefix = "GradeService CreateGradeAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.gradeService = new GradeService(context);

            var studentId = "TestStudent";
            var subjectId = "TestSubject";

            var testGrade = new GradeServiceModel
            {
                GradeValue  = "5",
                Term        = Term.Първи,
                IsTermGrade = true,
                StudentId   = studentId,
                SubjectId   = subjectId,
            };

            var actualResult = await this.gradeService.CreateGradeAsync(testGrade);

            Assert.True(!actualResult, errorMessagePrefix + " " + "Another term grade is added");
        }
Exemple #4
0
        public async Task EditSubject_WithExistentIdAndCorrectData_ShouldSuccessfullyEditSubject()
        {
            string errorMessagePrefix = "SubjectService EditSubjectAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.subjectService = new SubjectService(context);

            var testId = context.Subjects.First().Id;

            var testSubject = new SubjectServiceModel
            {
                Id   = testId,
                Name = "EditSubject",
            };

            var actualResult = await this.subjectService.EditSubjectAsync(testSubject);

            var editedSubject = context.Subjects.First();

            Assert.True(actualResult, errorMessagePrefix);

            Assert.True(editedSubject.Name == testSubject.Name, errorMessagePrefix + " " + "Subject Name is not set properly.");
        }
        public async Task GetAllUsersWithRoles_WithDummyData_ShouldReturnCorrectResults()
        {
            string errorMessagePrefix = "UserService GetAllUsersWithRoles() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.userService = new UserService(context);

            var actualResult = await this.userService.GetAllUsersWithRoles().ToListAsync();

            var expectedResult = await context.Users.To <UserServiceModel>().ToListAsync();

            var users = context.Users.OrderBy(x => x.FullName);

            Assert.True(actualResult.Count == expectedResult.Count, errorMessagePrefix);

            for (int i = 0; i < expectedResult.Count; i++)
            {
                var actualEntity   = actualResult[i];
                var expectedEntity = expectedResult[i];

                Assert.True(actualEntity.FullName == expectedEntity.FullName, errorMessagePrefix + " " + "User Full Name is not returned properly.");
                Assert.True(actualEntity.Email == expectedEntity.Email, errorMessagePrefix + " " + "User Email is not returned properly.");
                Assert.True(actualEntity.PhoneNumber == expectedEntity.PhoneNumber, errorMessagePrefix + " " + "User Phone Number is not returned properly.");
            }
        }
        public async Task GetAllStudentsInClass_WithExistentIdAndDummyData_ShouldReturnCorrectResults()
        {
            string errorMessagePrefix = "StudentService GetAllStudentsInClassAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.studentService = new StudentService(context);

            var testId = context.Classes.First().Id;

            var actualResult = await this.studentService.GetAllStudentsInClassAsync(testId);

            var expectedResult = await context.Students.Where(x => x.ClassId == testId).To <StudentServiceModel>().ToListAsync();

            Assert.True(actualResult.Count == expectedResult.Count, errorMessagePrefix);

            for (int i = 0; i < expectedResult.Count; i++)
            {
                var actualEntity   = actualResult[i];
                var expectedEntity = expectedResult[i];

                Assert.True(actualEntity.FullName == expectedEntity.FullName, errorMessagePrefix + " " + "Student Full Name is not returned properly.");
                Assert.True(actualEntity.PIN == expectedEntity.PIN, errorMessagePrefix + " " + "Student PIN is not returned properly.");
                Assert.True($"{actualEntity.Class.ClassNumber} {actualEntity.Class.ClassLetter}" == $"{expectedEntity.Class.ClassNumber} {expectedEntity.Class.ClassLetter}", errorMessagePrefix + " " + "Student Class Name is not returned properly.");
            }
        }
        public async Task GetStudentSubjects_WithExistentIdAndNonEmptyClass_ShouldReturnCorrectResults()
        {
            string errorMessagePrefix = "StudentService GetStudentSubjectsAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.studentService = new StudentService(context);

            var testId = "WithSubjects";

            var actualResult = await this.studentService.GetStudentSubjectsAsync(testId);

            var expectedResult = new List <ClassSubjectServiceModel>();

            var subjects = context.Students.Find(testId).Class.Subjects.OrderBy(x => x.Subject.Name).To <ClassSubjectServiceModel>().ToList();

            expectedResult = subjects;

            Assert.True(actualResult.Count == expectedResult.Count, errorMessagePrefix);

            for (int i = 0; i < expectedResult.Count; i++)
            {
                var actualEntity   = actualResult[i];
                var expectedEntity = expectedResult[i];

                Assert.True(actualEntity.Subject.Name == expectedEntity.Subject.Name, errorMessagePrefix + " " + "Subject Name is not returned properly.");
                Assert.True(actualEntity.Workload == expectedEntity.Workload, errorMessagePrefix + " " + "Subject Workload is not returned properly.");
            }
        }
        public async Task GetStudentToDisplay_WithExistentStudentPinAndZeroData_ShouldReturnEmptyResults()
        {
            string errorMessagePrefix = "StudentService GetStudentToDisplayAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            this.studentService = new StudentService(context);

            var student = new Student
            {
                PIN      = "TestPIN",
                FullName = "TestName",
                Absences = new List <Absence>(),
                Grades   = new List <Grade>(),
                Remarks  = new List <Remark>(),
                Class    = new Class {
                    ClassTeacher = new NetBookUser()
                },
            };

            await context.Students.AddAsync(student);

            await context.SaveChangesAsync();

            var actualResult = await this.studentService.GetStudentToDisplayAsync(student.PIN);

            var expectedResult = 0;

            Assert.True(actualResult.GradesForSubject.Count == expectedResult, errorMessagePrefix);
            Assert.True(actualResult.Absences.Count == expectedResult, errorMessagePrefix);
            Assert.True(actualResult.Remarks.Count == expectedResult, errorMessagePrefix);
        }
Exemple #9
0
        public async Task UpdateSchool_ShouldUpdateSchoolSuccessfully()
        {
            string errorMessagePrefix = "School UpdateAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.schoolService = new SchoolService(context);

            var testSchool = new SchoolServiceModel
            {
                Name         = "TestName1",
                Town         = "Test1",
                Municipality = "Test1",
                Region       = "Test1",
                Area         = "Test1",
            };

            var actualResult = await this.schoolService.UpdateAsync(testSchool);

            Assert.True(actualResult, errorMessagePrefix);

            var updatedSchool = context.School.First();

            Assert.True(updatedSchool.Name == testSchool.Name, errorMessagePrefix + " " + "School Name is not set properly.");
            Assert.True(updatedSchool.Town == testSchool.Town, errorMessagePrefix + " " + "School Town is not set properly.");
            Assert.True(updatedSchool.Municipality == testSchool.Municipality, errorMessagePrefix + " " + "School Municipality is not set properly.");
            Assert.True(updatedSchool.Region == testSchool.Region, errorMessagePrefix + " " + "School Region is not set properly.");
            Assert.True(updatedSchool.Area == testSchool.Area, errorMessagePrefix + " " + "School Area is not set properly.");
        }
        public async Task CreateSubject_WithCorrectData_ShouldSuccessfullyCreateSubject()
        {
            string errorMessagePrefix = "ClassService CreateSubjectAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.classService = new ClassService(context);

            var classId = "NoSubjectClasses";

            var testSubject = new ClassSubjectServiceModel
            {
                Id      = "TestCreateSubject",
                Subject = new SubjectServiceModel {
                    Name = "TestSubject"
                },
                Workload = 175,
                ClassId  = classId,
            };

            var actualResult = await this.classService.CreateSubjectAsync(testSubject);

            Assert.True(actualResult, errorMessagePrefix);

            var subject = context.SubjectClasses.Find("TestCreateSubject");

            Assert.True(subject.Subject.Name == testSubject.Subject.Name, errorMessagePrefix + " " + "Subject Name is not set properly.");
            Assert.True(subject.Workload == testSubject.Workload, errorMessagePrefix + " " + "Workload is not set properly.");
            Assert.True(subject.ClassId == testSubject.ClassId, errorMessagePrefix + " " + "ClassId is not set properly");
        }
        public async Task GetAllAbsences_WithExistentIdAndDummyData_ShouldReturnAllAbsences()
        {
            string errorMessagePrefix = "ClassService GetAllAbsences() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.classService = new ClassService(context);

            var testId = "WithAbsences";

            var actualResult = await this.classService.GetAllAbsences(testId).ToListAsync();

            var expectedResult = context.Students.Find(testId).Absences.To <AbsenceServiceModel>().ToList();

            Assert.True(actualResult.Count == expectedResult.Count, errorMessagePrefix);

            for (int i = 0; i < expectedResult.Count; i++)
            {
                var actualEntity   = actualResult[i];
                var expectedEntity = expectedResult[i];

                Assert.True(expectedEntity.SubjectId == actualEntity.SubjectId, errorMessagePrefix + " " + "SubjectId not returned properly");
                Assert.True(expectedEntity.StudentId == actualEntity.StudentId, errorMessagePrefix + " " + "StudentId not returned properly");
            }
        }
        public async Task GetAllRemarks_WithExistentIdAndDummyData_ShouldReturnCorrectResults()
        {
            string errorMessagePrefix = "ClassService GetAllRemarks() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.classService = new ClassService(context);

            var testId = "WithAbsences";

            var actualResult = await this.classService.GetAllRemarks(testId).ToListAsync();

            var expectedResult = context.Students.Find(testId).Remarks.OrderBy(x => x.Subject.Subject.Name).ThenBy(x => x.Text).To <RemarkServiceModel>().ToList();

            Assert.True(expectedResult.Count == actualResult.Count, errorMessagePrefix);

            for (int i = 0; i < expectedResult.Count; i++)
            {
                var actualEntity   = actualResult[i];
                var expectedEntity = expectedResult[i];

                Assert.True(expectedEntity.StudentId == actualEntity.StudentId, errorMessagePrefix + " " + "StudentId is not set properly.");
                Assert.True(expectedEntity.SubjectId == actualEntity.SubjectId, errorMessagePrefix + " " + "SubjectId is not set properly.");
                Assert.True(expectedEntity.Text == actualEntity.Text, errorMessagePrefix + " " + "Text is not set properly.");
            }
        }
        public async Task EditClass_WithCorrectData_ShouldSuccessfullyEditClass()
        {
            string errorMessagePrefix = "ClassService EditClassAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.classService = new ClassService(context);

            var testId = context.Classes.First().Id;

            var testEditClass = new ClassServiceModel
            {
                Id              = testId,
                ClassNumber     = 10,
                ClassLetter     = ClassLetter.Б,
                SchoolYearStart = 2017,
                SchoolYearEnd   = 2018,
            };

            var actualResult = await this.classService.EditClassAsync(testEditClass);

            var editedClass = context.Classes.First();

            Assert.True(actualResult, errorMessagePrefix);

            Assert.True(testEditClass.ClassNumber == editedClass.ClassNumber, errorMessagePrefix + " " + "ClassNumber is not set properly.");
            Assert.True(testEditClass.ClassLetter == editedClass.ClassLetter, errorMessagePrefix + " " + "ClassLetter is not set properly.");
            Assert.True(testEditClass.SchoolYearStart == editedClass.SchoolYearStart, errorMessagePrefix + " " + "SchoolYearStart is not set properly.");
            Assert.True(testEditClass.SchoolYearEnd == editedClass.SchoolYearEnd, errorMessagePrefix + " " + "SchoolYearEnd is not set properly.");
        }
        public async Task GetStudentClass_WithExistentId_ShouldSuccessfullyReturnClass()
        {
            string errorMessagePrefix = "ClassService GetStudentClassDropdownAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.classService = new ClassService(context);

            var classEntity = context.Classes.First();

            var testId = classEntity.Students.First().Id;

            var actualResult = await this.classService.GetStudentClassDropdownAsync(testId);

            var expectedResult = new List <SelectListItem>
            {
                new SelectListItem
                {
                    Text  = $"{classEntity.ClassNumber} {classEntity.ClassLetter}",
                    Value = classEntity.Id,
                },
            };

            Assert.Equal(expectedResult.Count, actualResult.Count);

            Assert.True(actualResult.First().Text == expectedResult.First().Text, errorMessagePrefix + " " + "ClassName is not returned properly.");
            Assert.True(actualResult.First().Value == expectedResult.First().Value, errorMessagePrefix + " " + "ClassId is not returned properly.");
        }
Exemple #15
0
        public async Task CreateRemark_WithCorrectData_ShouldSuccessfullyCreateRemark()
        {
            string errorMessagePrefix = "RemarkService CreateRemarkAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.remarkService = new RemarkService(context);

            var student = new Student {
                Id = "CreateRemark", Remarks = new List <Remark>(), Class = new Class()
            };

            await context.Students.AddAsync(student);

            await context.SaveChangesAsync();

            var testRemark = new RemarkServiceModel {
                Id = "TestRemark", StudentId = student.Id, Student = student.To <StudentServiceModel>()
            };

            var actualResult = await this.remarkService.CreateRemarkAsync(testRemark);

            var studentRemarks = context.Students.Find(student.Id).Remarks;

            Assert.True(actualResult, errorMessagePrefix);

            Assert.True(studentRemarks.Contains(context.Remarks.Find(testRemark.Id)), errorMessagePrefix + " " + "Remark is not added to student.");
        }
Exemple #16
0
        public async Task CreateGrade_WithCorrectData_ShouldSuccessfullyCreateGrade()
        {
            string errorMessagePrefix = "GradeService CreateGradeAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.gradeService = new GradeService(context);

            var student = context.Students.First();

            var testGrade = new GradeServiceModel
            {
                Id          = "TestCreateGrade",
                GradeValue  = "5",
                Term        = Term.Втори,
                IsTermGrade = false,
                Student     = student.To <StudentServiceModel>(),
                StudentId   = student.Id,
            };

            var actualResult = await this.gradeService.CreateGradeAsync(testGrade);

            var grade = context.Grades.Find("TestCreateGrade");

            Assert.True(actualResult, errorMessagePrefix);
            Assert.True(grade.GradeValue == testGrade.GradeValue, errorMessagePrefix + " " + "GradeValue is not set properly.");
            Assert.True(grade.Term == testGrade.Term, errorMessagePrefix + " " + "Term is not set properly.");
            Assert.True(grade.IsTermGrade == testGrade.IsTermGrade, errorMessagePrefix + " " + "IsTermGrade is not set properly.");
            Assert.True(grade.StudentId == testGrade.StudentId, errorMessagePrefix + " " + "StudentId is not set properly");
        }
        public async Task GetAllAbsences_WithDummyData_ShouldReturnCorrectResult()
        {
            string errorMessagePrefix = "AbsenceService GetAllAbsences() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.absenceService = new AbsenceService(context);

            List <AbsenceServiceModel> actualResult = await this.absenceService.GetAllAbsences().ToListAsync();

            List <AbsenceServiceModel> expectedResult = context.Absences.To <AbsenceServiceModel>().ToList();

            Assert.Equal(expectedResult.Count, actualResult.Count);

            for (int i = 0; i < expectedResult.Count; i++)
            {
                var expectedEntity = expectedResult[i];
                var actualEntity   = actualResult[i];

                Assert.True(expectedEntity.Student.FullName == actualEntity.Student.FullName, errorMessagePrefix + " " + "FullName is not returned properly");
                Assert.True($"{expectedEntity.Student.Class.ClassNumber} {expectedEntity.Student.Class.ClassLetter}" == $"{actualEntity.Student.Class.ClassNumber} {actualEntity.Student.Class.ClassLetter}", errorMessagePrefix + " " + "Class Name is not returned properly");
                Assert.True(expectedEntity.Subject.Subject.Name == actualEntity.Subject.Subject.Name, errorMessagePrefix + " " + "Subject Name is not returned properly");
            }
        }
Exemple #18
0
        public async Task GetAllRemarks_WithDummyData_ShouldReturnCorrectResults()
        {
            string errorMessagePrefix = "RemarkService GetAllRemarks() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.remarkService = new RemarkService(context);

            var actualResult = await this.remarkService.GetAllRemarks().ToListAsync();

            var expectedResult = await context.Remarks.To <RemarkServiceModel>().ToListAsync();

            Assert.True(actualResult.Count == expectedResult.Count, errorMessagePrefix);

            for (int i = 0; i < expectedResult.Count; i++)
            {
                var actualEntity   = actualResult[i];
                var expectedEntity = expectedResult[i];

                Assert.True(actualEntity.Text == expectedEntity.Text, errorMessagePrefix + " " + "Text is not returned properly.");
                Assert.True(actualEntity.Student.FullName == expectedEntity.Student.FullName, errorMessagePrefix + " " + "Student Full Name is not returned properly.");
                Assert.True(actualEntity.Subject.Subject.Name == expectedEntity.Subject.Subject.Name, errorMessagePrefix + " " + "Subject Name is not returned properly.");
            }
        }
        public async Task DeleteClass_WithExistentId_ShouldSuccessfullyDeleteClass()
        {
            string errorMessagePrefix = "ClassService DeleteClassAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.classService = new ClassService(context);

            var testId = context.Classes.First().Id;

            var actualResult = await this.classService.DeleteClassAsync(testId);

            var deletedClass = context.Classes.Find(testId);
            var students     = deletedClass.Students;
            var subjects     = deletedClass.Subjects;
            var teacher      = deletedClass.ClassTeacher;

            Assert.True(actualResult, errorMessagePrefix);
            Assert.True(deletedClass.IsDeleted, errorMessagePrefix + " " + "IsDeleted is not set properly.");
            Assert.True(teacher.IsDeleted, errorMessagePrefix + " " + "Teacher IsDeleted is not set properly.");

            foreach (var student in students)
            {
                Assert.True(student.IsDeleted, errorMessagePrefix + " " + "Student IsDeleted is not set properly.");
            }

            foreach (var subject in subjects)
            {
                Assert.True(subject.IsDeleted, errorMessagePrefix + " " + "Subject IsDeleted is not set properly.");
            }
        }
        public async Task GetAllClasses_WithDummyData_ShouldReturnCorrectResults()
        {
            string errorMessagePrefix = "ClassService GetAllClasses() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.classService = new ClassService(context);

            List <ClassServiceModel> actualResult = await this.classService.GetAllClasses().ToListAsync();

            List <ClassServiceModel> expectedResult = await context.Classes
                                                      .OrderBy(x => x.ClassNumber)
                                                      .ThenBy(x => x.ClassLetter)
                                                      .To <ClassServiceModel>().ToListAsync();

            Assert.Equal(expectedResult.Count, actualResult.Count);

            for (int i = 0; i < expectedResult.Count; i++)
            {
                var expectedEntity = expectedResult[i];
                var actualEntity   = actualResult[i];

                Assert.True($"{expectedEntity.ClassNumber} {expectedEntity.ClassLetter}" == $"{actualEntity.ClassNumber} {actualEntity.ClassLetter}", errorMessagePrefix + " " + "Class Name is not returned properly");
                Assert.True($"{expectedEntity.SchoolYearStart} {expectedEntity.SchoolYearEnd}" == $"{actualEntity.SchoolYearStart} {actualEntity.SchoolYearEnd}", errorMessagePrefix + " " + "Class Year is not returned properly");
                Assert.True(expectedEntity.ClassTeacher.FullName == actualEntity.ClassTeacher.FullName, errorMessagePrefix + " " + "ClassTeacher Full Name is not returned properly");
            }
        }
        public async Task CreateClass_WithNonExistentTeacher_ShouldThrowArgumentNullException()
        {
            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.classService = new ClassService(context);

            var testClass = new ClassServiceModel();

            await Assert.ThrowsAsync <ArgumentNullException>(async() => await this.classService.CreateClassAsync(testClass));
        }
        public async Task GetClassNumbersDropdown_ShouldReturnCorrectData()
        {
            string errorMessagePrefix = "ClassService GetClassNumbersDropdown() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.classService = new ClassService(context);

            var actualResult   = this.classService.GetClassNumbersDropdown();
            var expectedResult = new List <SelectListItem>
            {
                new SelectListItem
                {
                    Text  = "8",
                    Value = "8",
                },
                new SelectListItem
                {
                    Text  = "9",
                    Value = "9",
                },
                new SelectListItem
                {
                    Text  = "10",
                    Value = "10",
                },
                new SelectListItem
                {
                    Text  = "11",
                    Value = "11",
                },
                new SelectListItem
                {
                    Text  = "12",
                    Value = "12",
                },
            };

            Assert.Equal(expectedResult.Count, actualResult.Count);

            for (int i = 0; i < expectedResult.Count; i++)
            {
                var expectedEntry = expectedResult[i];
                var actualEntry   = actualResult[i];

                Assert.True(expectedEntry.Text == actualEntry.Text, errorMessagePrefix + " " + "ClassNumber is not returned properly.");
                Assert.True(expectedEntry.Value == actualEntry.Value, errorMessagePrefix + " " + "ClassNumber Value is not returned properly.");
            }
        }
        public async Task GetClassesDropdown_WithZeroData_ShouldReturnEmptyResults()
        {
            string errorMessagePrefix = "ClassService GetClassesDropdownAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            this.classService = new ClassService(context);

            var actualResult = await this.classService.GetClassesDropdownAsync();

            var expectedResult = 0;

            Assert.True(actualResult.Count == expectedResult, errorMessagePrefix);
        }
        public async Task GetClass_WithNonExistentId_ShouldThrowArgumentNullException()
        {
            string errorMessagePrefix = "ClassService GetClassById() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.classService = new ClassService(context);

            string testId = "Non_Existent";

            Assert.Throws <ArgumentNullException>(() => this.classService.GetClassById(testId));
        }
        public async Task CreateSubject_WithIncorrectData_ShouldThrowArgumentNullException()
        {
            string errorMessagePrefix = "ClassService CreateSubjectAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.classService = new ClassService(context);

            var testSubject = new ClassSubjectServiceModel();

            await Assert.ThrowsAsync <ArgumentNullException>(async() => await this.classService.CreateSubjectAsync(testSubject));
        }
Exemple #26
0
        public async Task CreateRemark_WithNonExistentStudent_ShouldThrowArgumentNullException()
        {
            string errorMessagePrefix = "RemarkService CreateRemarkAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.remarkService = new RemarkService(context);

            var testRemark = new RemarkServiceModel();

            await Assert.ThrowsAsync <ArgumentNullException>(async() => await this.remarkService.CreateRemarkAsync(testRemark));
        }
Exemple #27
0
        public async Task DeleteSubject_WithNonExistentId_ShouldThrowArgumentNullException()
        {
            string errorMessagePrefix = "SubjectService DeleteSubjectAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.subjectService = new SubjectService(context);

            var testId = "Non_Existent";

            await Assert.ThrowsAsync <ArgumentNullException>(async() => await this.subjectService.DeleteSubjectAsync(testId));
        }
        public async Task GetStudentToDisplay_WithNonExistentPin_ShouldThrowArgumentNullException()
        {
            string errorMessagePrefix = "StudentService GetStudentToDisplayAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.studentService = new StudentService(context);

            var testPin = "Non_Existent";

            await Assert.ThrowsAsync <ArgumentNullException>(async() => await this.studentService.GetStudentToDisplayAsync(testPin));
        }
        public async Task GetAllStudentsInClassDropdown_WithNonExistentClassId_ShouldThrowArgumentNullException()
        {
            string errorMessagePrefix = "ClassService GetAllStudentsInClassDropdownAsync() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            await this.SeedData(context);

            this.classService = new ClassService(context);

            var testId = "Non_Existent";

            await Assert.ThrowsAsync <ArgumentNullException>(async() => await this.classService.GetAllStudentsInClassDropdownAsync(testId));
        }
        public async Task GetAllAbsences_WithZeroData_ShouldReturnEmptyResults()
        {
            string errorMessagePrefix = "AbsenceService GetAllAbsences() does not work properly.";

            var context = NetBookDbContextInMemoryFactory.InitializeContext();

            this.absenceService = new AbsenceService(context);

            List <AbsenceServiceModel> actualResult = await this.absenceService.GetAllAbsences().ToListAsync();

            int expectedResult = 0;

            Assert.True(actualResult.Count == expectedResult, errorMessagePrefix);
        }