Beispiel #1
0
        public async void GetCourseById_NoCourseFound_NotFoundResult()
        {
            // Arrange
            var mockCourseRepo = new Mock <IRepositoryAsync <Course> >();
            var controller     = new CourseController(null, mockCourseRepo.Object);

            // Act
            var result = await controller.GetCourseById(1);

            // Assert
            Assert.IsType <NotFoundResult>(result);
        }
Beispiel #2
0
        public async Task CanGetALocationById()
        {
            var id = "1";

            courseService.Setup(repo => repo.GetCourseByIdAsync(id)).ReturnsAsync(GetTestCourseById(id));

            var result = await controller.GetCourseById(id);

            // Assertions
            Assert.IsInstanceOf <ActionResult <Entities.Course> >(result);
            var resultObject = GetObjectResultContent(result);

            Assert.AreEqual(resultObject.Id, id);
        }
Beispiel #3
0
        public void GetProductById_Success_Result()
        {
            var getCoursetByIdRequestModel = new GetCourseByIdRequestModel();

            Mediator.Setup(x => x.Send(It.IsAny <GetCourseByIdRequestModel>(), new CancellationToken())).
            ReturnsAsync(new GetCourseByIdResponseModel());

            var courseController = new CourseController(Mediator.Object);

            //Action
            var result = courseController.GetCourseById(new Guid());

            //Assert
            Assert.IsType <OkObjectResult>(result.Result);
        }
Beispiel #4
0
        public void Execute()
        {
            Console.Clear();
            courseController.GetAllCourses();
            Console.Write("Enter course Id: ");
            Int32.TryParse(Console.ReadLine(), out int courseId);
            var courseVM = courseController.GetCourseById(courseId);

            if (userController.AddCourseToUserProgress(courseVM))
            {
                courseController.GetCourseMaterials(courseVM);
                courseController.PassCourseMaterials();
                userController.UserPassCourse(courseVM);
            }
        }
Beispiel #5
0
        public async void GetCourseById_OkObjectResult()
        {
            // Arrange
            int id             = 1;
            var mockCourseRepo = new Mock <IRepositoryAsync <Course> >();

            mockCourseRepo.Setup(repo => repo.FindAsync(id)).ReturnsAsync(new Course());
            var controller = new CourseController(null, mockCourseRepo.Object);

            // Act
            var result = await controller.GetCourseById(id) as ObjectResult;

            // Assert
            var resultObject = Assert.IsType <OkObjectResult>(result);
            var course       = Assert.IsAssignableFrom <Course>(result.Value);
        }