public void PutCourseShouldReturnNotFound()
        {
            // Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            courseRepo        = new MockCourseRepo(testSchoolRegisterContext);
            coursesController = new CoursesController(courseRepo);

            //Act
            IHttpActionResult actionResult = coursesController.Put(1, new Course {
                Id = 1
            });

            //Assert
            Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult));
        }
        public void PutTeacher_ShouldReturnBadRequestDifferentId()
        {
            // Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            teacherRepo        = new MockTeacherRepo(testSchoolRegisterContext);
            teachersController = new TeachersController(teacherRepo);

            //Act
            IHttpActionResult actionResult = teachersController.PutTeacher("notExistingTeacherId", new Teacher {
                Id = "sampleTeacherId"
            });

            //Assert
            Assert.IsInstanceOfType(actionResult, typeof(BadRequestResult));
        }
        public void GetTeacher_ShouldReturnForbidden()
        {
            //Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            teacherRepo        = new MockTeacherRepo(testSchoolRegisterContext);
            teachersController = new TeachersController(teacherRepo);
            PopulateTeacherFields();

            //Act
            var actionResult = teachersController.GetTeacher("unauthenticatedTeacherId") as ResponseMessageResult;


            //Assert
            Assert.IsNotNull(actionResult);
            Assert.AreEqual(actionResult.Response.StatusCode, HttpStatusCode.Forbidden);
        }
        public void GetTeacher_ShouldReturnNotFound()
        {
            //Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            teacherRepo        = new MockTeacherRepo(testSchoolRegisterContext);
            teachersController = new TeachersController(teacherRepo);
            PopulateTeacherFields();

            //Act
            var actionResult = teachersController.GetTeacher("notExistingTeacherId");


            //Assert
            Assert.IsNotNull(actionResult);
            Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult));
        }
        public void GetLessonsByCourseId_ShouldReturnOk(int id)
        {
            //Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            courseRepo        = new MockCourseRepo(testSchoolRegisterContext);
            coursesController = new CoursesController(courseRepo);
            PopulateCourseFields();

            //Act
            var actionResult  = coursesController.GetLessonsByCourseId(1);
            var contentResult = actionResult as OkNegotiatedContentResult <ICollection <LessonDto> >;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
        }
Пример #6
0
        public void GetStudent_ShouldReturnForbidden()
        {
            //Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            studentRepo        = new MockStudentRepo(testSchoolRegisterContext);
            studentsController = new StudentsController(studentRepo);
            PopulateStudentFields();

            //Act
            var actionResult = studentsController.GetStudent("unauthenticatedStudentId") as ResponseMessageResult;


            //Assert
            Assert.IsNotNull(actionResult);
            Assert.AreEqual(actionResult.Response.StatusCode, HttpStatusCode.Forbidden);
        }
Пример #7
0
        public void GetStudent_ShouldReturnNotFound()
        {
            //Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            studentRepo        = new MockStudentRepo(testSchoolRegisterContext);
            studentsController = new StudentsController(studentRepo);
            PopulateStudentFields();

            //Act
            var actionResult = studentsController.GetStudent("notExistingStudentId");


            //Assert
            Assert.IsNotNull(actionResult);
            Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult));
        }
Пример #8
0
        public void PutStudent_ShouldReturnNotFound()
        {
            // Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            studentRepo        = new MockStudentRepo(testSchoolRegisterContext);
            studentsController = new StudentsController(studentRepo);

            //Act
            IHttpActionResult actionResult =
                studentsController.PutStudent("sampleStudentId", new Student {
                Id = "sampleStudentId"
            });

            //Assert
            Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult));
        }
        public void GetTeacher_ShouldReturnOk()
        {
            //Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            teacherRepo        = new MockTeacherRepo(testSchoolRegisterContext);
            teachersController = new TeachersController(teacherRepo);
            PopulateTeacherFields();

            //Act
            var actionResult  = teachersController.GetTeacher("sampleTeacherId");
            var contentResult = actionResult as OkNegotiatedContentResult <TeacherBasicDto>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual("sampleTeacherId", contentResult.Content.Id);
        }
        public void GetAttendance_ShouldReturnOk()
        {
            //Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            attendanceRepo            = new MockAttendanceRepo(testSchoolRegisterContext);
            attendancesController     = new AttendancesController(attendanceRepo);
            PopulateAttendanceFields();

            //Act
            var actionResult  = attendancesController.Get(1);
            var contentResult = actionResult as OkNegotiatedContentResult <AttendanceDto>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(1, contentResult.Content.Id);
        }
Пример #11
0
        public void GetMark_ShouldReturnOk()
        {
            //Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            markRepo        = new MockMarkRepo(testSchoolRegisterContext);
            marksController = new MarksController(markRepo);
            PopulateMarkFields();

            //Act
            var actionResult  = marksController.Get(1);
            var contentResult = actionResult as OkNegotiatedContentResult <MarkDto>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(1, contentResult.Content.Id);
        }
        public void GetCourses_ShouldReturnOk()
        {
            //Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            courseRepo        = new MockCourseRepo(testSchoolRegisterContext);
            coursesController = new CoursesController(courseRepo);
            PopulateCourseFields();

            //Act

            IHttpActionResult actionResult = coursesController.GetCourses();
            var contentResult = actionResult as OkNegotiatedContentResult <IQueryable <CourseDto> >;

            //Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
        }
Пример #13
0
        public void GetStudent_ShouldReturnOk()
        {
            //Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            studentRepo        = new MockStudentRepo(testSchoolRegisterContext);
            studentsController = new StudentsController(studentRepo);
            PopulateStudentFields();

            //Act
            var actionResult  = studentsController.GetStudent("sampleStudentId");
            var contentResult = actionResult as OkNegotiatedContentResult <StudentBasicDto>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual("sampleStudentId", contentResult.Content.Id);
        }
        public void PostAttendance_ShouldReturnOk()
        {
            //Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            attendanceRepo            = new MockAttendanceRepo(testSchoolRegisterContext);
            attendancesController     = new AttendancesController(attendanceRepo);
            PopulateAttendanceFields();
            Attendance attendance = new Attendance()
            {
                Id = 1
            };

            //Act
            var actionResult = attendancesController.PostAttendance(attendance);

            // Assert
            Assert.IsNotNull(actionResult);
        }
Пример #15
0
        public void PostMark_ShouldReturnOk()
        {
            //Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            markRepo        = new MockMarkRepo(testSchoolRegisterContext);
            marksController = new MarksController(markRepo);
            PopulateMarkFields();
            Mark mark = new Mark()
            {
                Id = 1
            };

            //Act
            var actionResult = marksController.PostMark(mark);

            // Assert
            Assert.IsNotNull(actionResult);
        }
        public void PutCourseShouldReturnAccepted()
        {
            // Arrange
            testSchoolRegisterContext = new TestSchoolRegisterContext();
            courseRepo        = new MockCourseRepo(testSchoolRegisterContext);
            coursesController = new CoursesController(courseRepo);
            PopulateCourseFields();

            // Act
            IHttpActionResult actionResult = coursesController.Put(1, new Course {
                Id = 1
            });
            var contentResult = actionResult as NegotiatedContentResult <Course>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.AreEqual(HttpStatusCode.Accepted, contentResult.StatusCode);
            Assert.IsNotNull(contentResult.Content);
        }