Example #1
0
        public void GetCourseLessonStep_ValidTest()
        {
            var response = controller.GetLessonStep(courseProgressData.Id, lessonId: 0, stepId: 0).Result;

            var expectedResult = courseProgressData.LessonProgresses[0].StepProgresses[0];

            Utilits.CheckResponseValue <OkObjectResult, StepProgressData>(response, expectedResult);
        }
Example #2
0
        public void GetLessonByIdTest()
        {
            var response = controller.GetLessonById(courseData.Id, 0).Result;

            var expecteResult = course.Lessons[0];

            Utilits.CheckResponseValue <OkObjectResult, Lesson>(response, expecteResult);
        }
Example #3
0
        public void StartCourseTest_ValidTest()
        {
            var response = controller.StartCourse(new CourseStartOptions {
                CourseId = courseData.Id
            }, null).Result;

            Utilits.CheckResponseValue <CreatedResult, CourseProgressData>(response, courseProgressData);
        }
Example #4
0
        public void GetAllStepsTest()
        {
            var response = controller.GetAllSteps(courseData.Id, 0).Result;

            var expectedResult = course.Lessons[0].Steps;

            Utilits.CheckResponseValue <OkObjectResult, List <LessonStep> >(response, expectedResult);
        }
Example #5
0
        public void GetAllCoursesTest()
        {
            var response = controller.GetAllCourses().Result;

            Utilits.CheckResponseValue <OkObjectResult, List <Course> >(response, new List <Course> {
                course
            });
        }
Example #6
0
        public void GetAllCoursesProgressesTest_ValidTest()
        {
            var response = controller.GetAllCoursesProgresses(null).Result;

            Utilits.CheckResponseValue <OkObjectResult, List <CourseProgressData> >(
                response,
                new List <CourseProgressData> {
                courseProgressData
            });
        }
Example #7
0
        public void GetCourseWithInvalidIdTest()
        {
            var invalidId = ObjectId.GenerateNewId().ToString();
            var response  = controller.GetCourse(invalidId).Result;

            var expectedResult = new Error {
                Code = Error.ErrorCode.NotFound, Message = $"Invalid course id = {invalidId}"
            };

            Utilits.CheckResponseValue <NotFoundObjectResult, Error>(response, expectedResult);
        }
Example #8
0
        public void GetCourseProgress_InvalidUrl()
        {
            var invalidId = ObjectId.GenerateNewId().ToString();
            var response  = controller.GetCourseProgress(invalidId).Result;

            var expectedValue = new Error
            {
                Code    = Error.ErrorCode.NotFound,
                Message = $"Invalid progressId = {invalidId}"
            };

            Utilits.CheckResponseValue <NotFoundObjectResult, Error>(response, expectedValue);
        }
        public void GetIdTest()
        {
            var repo = new Mock <IUserRepository>();

            repo
            .Setup(x => x.GetByLoginAsync(registrationInfo.Login))
            .Returns(() => Task.FromResult(userData));

            var usersController = new UsersController(repo.Object);

            var response = usersController.GetId(registrationInfo.Login).Result;

            Utilits.CheckResponseValue <OkObjectResult, string>(response, userData.Id);
        }
        public void PostInvalidUserTest()
        {
            var usersController = new UsersController(null);
            var invalidUser     = new RegistrationInfo();

            var response = usersController.PostUser(invalidUser).Result;

            var extectedResult = new Error
            {
                Code    = Error.ErrorCode.BadArgument,
                Message = "Invalid user object"
            };

            Utilits.CheckResponseValue <BadRequestObjectResult, Error>(response, extectedResult);
        }
Example #11
0
        public void PostAnswerTest()
        {
            const int lessonId   = 0;
            const int stepId     = 0;
            const int questionId = 0;

            var answer = new Answer {
                QuestionId = questionId, SelectedAnswers = new List <int> {
                    0
                }
            };
            var result = controller.PostAnswer(courseProgressData.Id, lessonId, stepId, answer).Result;

            var question      = courseData.Lessons[lessonId].Steps[stepId].Questions[questionId];
            var expectedValue = question.GetQuestionState().Update(question, answer.SelectedAnswers);

            expectedValue.ProgressId = courseProgressData.Id;
            Utilits.CheckResponseValue <OkObjectResult, QuestionStateData>(result, expectedValue);
        }
        public void PostExistingUserTest()
        {
            var repo = new Mock <IUserRepository>();

            repo
            .Setup(x => x.ContainsByLoginAsync(registrationInfo.Login))
            .Returns(() => Task.FromResult(true));

            var usersController = new UsersController(repo.Object);

            var response = usersController.PostUser(registrationInfo).Result;

            var extectedResult = new Error {
                Code    = Error.ErrorCode.InvalidOperation,
                Message = $"User with login {registrationInfo.Login} already exists"
            };

            Utilits.CheckResponseValue <BadRequestObjectResult, Error>(response, extectedResult);
        }
Example #13
0
        public void GetCourseTest_ValidTest()
        {
            var response = controller.GetCourseProgress(courseProgressData.Id).Result;

            Utilits.CheckResponseValue <OkObjectResult, CourseProgressData>(response, courseProgressData);
        }
Example #14
0
        public void GetDescriptionTest()
        {
            var response = controller.GetDescription(courseData.Id).Result;

            Utilits.CheckResponseValue <OkObjectResult, Description>(response, course.Description);
        }
Example #15
0
        public void GetCourseTest()
        {
            var response = controller.GetCourse(courseData.Id).Result;

            Utilits.CheckResponseValue <OkObjectResult, Course>(response, course);
        }