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); }
public void GetLessonByIdTest() { var response = controller.GetLessonById(courseData.Id, 0).Result; var expecteResult = course.Lessons[0]; Utilits.CheckResponseValue <OkObjectResult, Lesson>(response, expecteResult); }
public void StartCourseTest_ValidTest() { var response = controller.StartCourse(new CourseStartOptions { CourseId = courseData.Id }, null).Result; Utilits.CheckResponseValue <CreatedResult, CourseProgressData>(response, courseProgressData); }
public void GetAllStepsTest() { var response = controller.GetAllSteps(courseData.Id, 0).Result; var expectedResult = course.Lessons[0].Steps; Utilits.CheckResponseValue <OkObjectResult, List <LessonStep> >(response, expectedResult); }
public void GetAllCoursesTest() { var response = controller.GetAllCourses().Result; Utilits.CheckResponseValue <OkObjectResult, List <Course> >(response, new List <Course> { course }); }
public void GetAllCoursesProgressesTest_ValidTest() { var response = controller.GetAllCoursesProgresses(null).Result; Utilits.CheckResponseValue <OkObjectResult, List <CourseProgressData> >( response, new List <CourseProgressData> { courseProgressData }); }
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); }
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); }
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); }
public void GetCourseTest_ValidTest() { var response = controller.GetCourseProgress(courseProgressData.Id).Result; Utilits.CheckResponseValue <OkObjectResult, CourseProgressData>(response, courseProgressData); }
public void GetDescriptionTest() { var response = controller.GetDescription(courseData.Id).Result; Utilits.CheckResponseValue <OkObjectResult, Description>(response, course.Description); }
public void GetCourseTest() { var response = controller.GetCourse(courseData.Id).Result; Utilits.CheckResponseValue <OkObjectResult, Course>(response, course); }