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); }
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); }
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); }