public void TestAddTutorCourse() { var mockUserSet = CreateMockUserSet(); mockUserSet.SetReturnsDefault(mockUserSet.Object.Cast <Tutor>()); _mockStudentExchangeDataContext.Setup(c => c.Users).Returns(mockUserSet.Object); var mockCoursesSet = CreateMockCoursesOfStudySet(); _mockStudentExchangeDataContext.Setup(c => c.CoursesOfStudy).Returns(mockCoursesSet.Object); _mockStudentExchangeDataContext.Setup(c => c.SaveChanges()); _tutorService.AddTutorCourse("testId2", 2L); _mockStudentExchangeDataContext.Verify(c => c.SaveChanges(), Times.Once); }
public IHttpActionResult PostCourse(long courseId) { _tutorService.AddTutorCourse(GetCurrentUserId(), courseId); return(Content(HttpStatusCode.NoContent, "")); }