Exemplo n.º 1
0
        public async Task CanAddNewCourseLesson()
        {
            var mockRepo = new Mock <ICreateCourseRepo>();
            var request  = new AddLessonRequest(Guid.Empty, "First Lesson", "https://www.google.com");

            var controller = new CreateCourseController(mockRepo.Object);

            controller.ObjectValidator = validator().Object;

            var result = await controller.AddLesson(request);

            mockRepo.Verify(m => m.AddLesson(It.IsAny <Guid>(), It.IsAny <Lesson>()), Times.Once);
        }
Exemplo n.º 2
0
        public async Task CanRemoveCourseLesson()
        {
            var mockRepo = new Mock <ICreateCourseRepo>();

            var controller = new CreateCourseController(mockRepo.Object);

            controller.ObjectValidator = validator().Object;

            var id     = Guid.NewGuid();
            var result = await controller.RemoveLesson(id);

            mockRepo.Verify(m => m.RemoveLesson(id), Times.Once);
        }
Exemplo n.º 3
0
        public async Task CreatesNewCourseSavesToDb()
        {
            var mockRepo = new Mock <ICreateCourseRepo>();
            var request  = new CreateCourseRequest("This is a course", "https://www.google.com", "Most awesome course ever", UserLevel.Beginner);
            var model    = new CourseOverview(Guid.Empty, "", "", "", 2, UserLevel.Beginner, null);

            mockRepo.Setup(p => p.Create(It.IsAny <CourseOverview>())).ReturnsAsync(model);


            var controller = new CreateCourseController(mockRepo.Object);

            controller.ObjectValidator = validator().Object;
            var result = await controller.AddCourse(request);

            mockRepo.Verify(m => m.Create(It.IsAny <CourseOverview>()), Times.Once);
        }