Example #1
0
        public void TestGetCourseById()
        {
            var mockCoursesSet = CreateMockCoursesOfStudySet();

            mockCoursesSet.Setup(x => x.Include(It.IsAny <string>())).Returns(mockCoursesSet.Object);
            _mockStudentExchangeDataContext.Setup(c => c.CoursesOfStudy).Returns(mockCoursesSet.Object);
            var result = _courseOfStudyService.GetCourseById(1L);

            Assert.AreSame(_courseOfStudySet.ToList().Find(c => c.Id == 1L), result);
        }
        public void AddGroup(Group group, long courseOfStudyId, string creatorId)
        {
            var newGroup = new Group()
            {
                Name           = group.Name,
                CourseOfStudy  = _courseOfStudyService.GetCourseById(courseOfStudyId),
                Administrators = new List <Student>()
                {
                    _studentExchangeDataContext.Users.OfType <Student>().ToList().Find(s => s.Id == creatorId)
                }
            };

            _studentExchangeDataContext.Groups.Add(newGroup);
            _studentExchangeDataContext.SaveChanges();
        }
 public IHttpActionResult Get(long id)
 {
     return(Content(HttpStatusCode.OK, _courseOfStudyService.GetCourseById(id)));
 }