Exemple #1
0
        public void GetUser()
        {
            var token = InstanceFactory.AuthorizedUserId();
            var user  = UserService.Get(token);

            Assert.IsNotNull(user);
        }
Exemple #2
0
        public void GetByName()
        {
            var token      = InstanceFactory.AuthorizedUserId();
            var userById   = UserService.Get(token);
            var userByName = UserService.Get(userById.Login);

            Assert.AreEqual(token, userByName.Id);
        }
        public void CreateTest()
        {
            var userId = InstanceFactory.AuthorizedUserId();
            var course = InstanceFactory.Course();

            var createdCourse = CourseService.Create(course, userId);

            Assert.AreNotEqual(createdCourse.Id, Guid.Empty);
        }
Exemple #4
0
        public void CreatorIsMentor()
        {
            Guid   creator = InstanceFactory.AuthorizedUserId();
            Course course  = InstanceFactory.Course();

            Course createdCourse = _courseService.Create(course, creator);
            ICollection <PeerReviewUser> members = _memberService.GetMentors(createdCourse.Id);

            Assert.IsTrue(members.Any(c => c.Id == creator));
        }
        public void GetByName()
        {
            var token  = InstanceFactory.AuthorizedUserId();
            var course = InstanceFactory.Course();

            var createdCourse = CourseService.Create(course, token);
            var courseByName  = CourseService.FindCourses(createdCourse.Title);

            Assert.AreEqual(1, courseByName.Count(c => c.Id == createdCourse.Id));
        }
        public void GetById()
        {
            var userId = InstanceFactory.AuthorizedUserId();
            var course = InstanceFactory.Course();

            var createdCourse = CourseService.Create(course, userId);
            var courseById    = CourseService.Get(createdCourse.Id);

            Assert.IsNotNull(courseById);
        }
Exemple #7
0
        public void DenyInvite_ExceptionNoInvite()
        {
            Guid   creator   = InstanceFactory.AuthorizedUserId();
            Guid   otherUser = InstanceFactory.AuthorizedUserId();
            Course course    = InstanceFactory.Course();

            Course createdCourse = _courseService.Create(course, creator);

            Assert.ThrowsException <ArgumentException>(()
                                                       => _memberService.DenyInvite(createdCourse.Id, otherUser));
        }
        public void UpdateCourse_WithoutPermission()
        {
            var token     = InstanceFactory.AuthorizedUserId();
            var otherUser = InstanceFactory.AuthorizedUserId();
            var course    = InstanceFactory.Course();

            var createdCourse = CourseService.Create(course, token);

            Assert.ThrowsException <PermissionDeniedException>(()
                                                               => CourseService.Update(createdCourse, otherUser));
        }
Exemple #9
0
        public void Update_NoPermission()
        {
            var token     = InstanceFactory.AuthorizedUserId();
            var otherUser = InstanceFactory.AuthorizedUserId();

            var user    = UserService.Get(token);
            var newName = InstanceFactory.GenerateString();

            user.FirstName = newName;
            Assert.ThrowsException <PermissionDeniedException>(() => UserService.Update(user, otherUser));
        }
Exemple #10
0
        public void Update_Ok()
        {
            var token   = InstanceFactory.AuthorizedUserId();
            var user    = UserService.Get(token);
            var newName = InstanceFactory.GenerateString();

            user.FirstName = newName;
            UserService.Update(user, token);
            var updatedUser = UserService.Get(token);

            Assert.AreEqual(newName, updatedUser.FirstName);
        }
        public void DeleteCourse()
        {
            var token  = InstanceFactory.AuthorizedUserId();
            var course = InstanceFactory.Course();

            var createdCourse = CourseService.Create(course, token);

            CourseService.Delete(createdCourse.Id, token);
            var deletedCourse = CourseService.Get(createdCourse.Id);

            Assert.IsNull(deletedCourse);
        }
Exemple #12
0
        public void InviteMember_AlreadyInvited()
        {
            Guid   creator   = InstanceFactory.AuthorizedUserId();
            Guid   otherUser = InstanceFactory.AuthorizedUserId();
            Course course    = InstanceFactory.Course();

            Course createdCourse = _courseService.Create(course, creator);

            _memberService.SendInvite(createdCourse.Id, otherUser, creator);

            Assert.ThrowsException <InvalidOperationException>(()
                                                               => _memberService.SendInvite(createdCourse.Id, otherUser, creator));
        }
Exemple #13
0
        public void AcceptInvite_IsMember()
        {
            Guid   creator   = InstanceFactory.AuthorizedUserId();
            Guid   otherUser = InstanceFactory.AuthorizedUserId();
            Course course    = InstanceFactory.Course();

            Course createdCourse = _courseService.Create(course, creator);

            _memberService.SendInvite(createdCourse.Id, otherUser, creator);
            _memberService.AcceptInvite(createdCourse.Id, otherUser);

            Assert.IsTrue(_memberService.IsMember(createdCourse.Id, otherUser));
        }
        public void GetTaskInCourse()
        {
            var token  = InstanceFactory.AuthorizedUserId();
            var course = InstanceFactory.Course();

            course = _courseService.Create(course, token);

            var courseTask  = InstanceFactory.CourseTask(token, course.Id);
            var createdTask = _courseTaskService.Create(courseTask, token);
            var taskInList  = _courseTaskService.GetTaskInCourse(course.Id, token);

            Assert.AreEqual(1, taskInList.Count(t => t.Id == createdTask.Id));
        }
Exemple #15
0
        public void InviteMember()
        {
            Guid   creator   = InstanceFactory.AuthorizedUserId();
            Guid   otherUser = InstanceFactory.AuthorizedUserId();
            Course course    = InstanceFactory.Course();

            Course createdCourse = _courseService.Create(course, creator);

            _memberService.SendInvite(createdCourse.Id, otherUser, creator);
            ICollection <Course> invites = _memberService.GetUserInvitations(otherUser);

            Assert.IsTrue(invites.Any(c => c.Id == createdCourse.Id));
        }
        public void CreateTask()
        {
            var token  = InstanceFactory.AuthorizedUserId();
            var course = InstanceFactory.Course();

            course = _courseService.Create(course, token);

            var courseTask  = InstanceFactory.CourseTask(token, course.Id);
            var createdTask = _courseTaskService.Create(courseTask, token);

            Assert.IsNotNull(createdTask);
            Assert.AreEqual(token, createdTask.AuthorId);
            Assert.AreEqual(course.Id, createdTask.CourseId);
        }
        public void UpdateCourse()
        {
            var token  = InstanceFactory.AuthorizedUserId();
            var course = InstanceFactory.Course();

            var createdCourse = CourseService.Create(course, token);
            var newTitle      = InstanceFactory.GenerateString();

            createdCourse.Title = newTitle;
            CourseService.Update(createdCourse, token);
            var updatedCourse = CourseService.Update(course, token);

            Assert.AreEqual(newTitle, updatedCourse.Title);
        }
Exemple #18
0
        public void AcceptInvite_InMemberList()
        {
            Guid   creator   = InstanceFactory.AuthorizedUserId();
            Guid   otherUser = InstanceFactory.AuthorizedUserId();
            Course course    = InstanceFactory.Course();

            Course createdCourse = _courseService.Create(course, creator);

            _memberService.SendInvite(createdCourse.Id, otherUser, creator);
            _memberService.AcceptInvite(createdCourse.Id, otherUser);
            ICollection <PeerReviewUser> members = _memberService.GetMembers(createdCourse.Id);

            Assert.IsTrue(members.Any(c => c.Id == otherUser));
        }
        public void DeleteTask()
        {
            var token  = InstanceFactory.AuthorizedUserId();
            var course = InstanceFactory.Course();

            course = _courseService.Create(course, token);

            var courseTask  = InstanceFactory.CourseTask(token, course.Id);
            var createdTask = _courseTaskService.Create(courseTask, token);

            _courseTaskService.Delete(createdTask.Id, token);
            var taskInList = _courseTaskService.Get(createdTask.Id, token);

            Assert.IsNull(taskInList);
        }
Exemple #20
0
        public void CreateSolution()
        {
            var token  = InstanceFactory.AuthorizedUserId();
            var course = InstanceFactory.Course();

            course = _courseService.Create(course, token);
            var courseTask = InstanceFactory.CourseTask(token, course.Id);

            courseTask = _courseTaskService.Create(courseTask, token);

            var solution        = InstanceFactory.Solution(token, courseTask.Id);
            var createdSolution = _solutionService.Create(solution, token);

            Assert.IsNotNull(createdSolution);
            Assert.AreEqual(token, createdSolution.AuthorId);
            Assert.AreEqual(courseTask.Id, createdSolution.CourseTaskId);
        }
Exemple #21
0
        public void CreateReview()
        {
            var token  = InstanceFactory.AuthorizedUserId();
            var course = InstanceFactory.Course();

            course = _courseService.Create(course, token);
            var courseTask = InstanceFactory.CourseTask(token, course.Id);

            courseTask = _courseTaskService.Create(courseTask, token);
            var solution = InstanceFactory.Solution(token, courseTask.Id);

            solution = _solutionService.Create(solution, token);

            var review        = InstanceFactory.Review(token, solution.Id, courseTask);
            var createdReview = _reviewService.Create(review, token);

            Assert.IsNotNull(createdReview);
        }
Exemple #22
0
        public void DeleteSolution()
        {
            var token  = InstanceFactory.AuthorizedUserId();
            var course = InstanceFactory.Course();

            course = _courseService.Create(course, token);
            var courseTask = InstanceFactory.CourseTask(token, course.Id);

            courseTask = _courseTaskService.Create(courseTask, token);

            var solution = InstanceFactory.Solution(token, courseTask.Id);

            solution = _solutionService.Create(solution, token);
            _solutionService.Delete(solution.Id, token);
            var deletedSolution = _solutionService.Get(solution.Id, token);

            Assert.IsNull(deletedSolution);
        }
Exemple #23
0
        public void GetTaskSolution()
        {
            Guid   userId = InstanceFactory.AuthorizedUserId();
            Course course = InstanceFactory.Course();

            course = _courseService.Create(course, userId);

            CourseTask courseTask = InstanceFactory.CourseTask(userId, course.Id);

            courseTask = _courseTaskService.Create(courseTask, userId);

            CourseSolution solution = InstanceFactory.Solution(userId, courseTask.Id);

            solution = _solutionService.Create(solution, userId);
            ICollection <CourseSolution> solutions = _solutionService.GetSolutionsByTask(courseTask.Id, userId);

            Assert.IsNotNull(solutions);
            Assert.AreEqual(1, solutions.Count(s => s.AuthorId == userId));
        }
Exemple #24
0
        public void GetSolutionReviews()
        {
            var token  = InstanceFactory.AuthorizedUserId();
            var course = InstanceFactory.Course();

            course = _courseService.Create(course, token);
            var courseTask = InstanceFactory.CourseTask(token, course.Id);

            courseTask = _courseTaskService.Create(courseTask, token);
            var solution = InstanceFactory.Solution(token, courseTask.Id);

            solution = _solutionService.Create(solution, token);

            var review        = InstanceFactory.Review(token, solution.Id, courseTask);
            var createdReview = _reviewService.Create(review, token);
            var reviews       = _reviewService.GetReviewsBySolution(solution.Id, token);

            Assert.IsNotNull(reviews);
            Assert.AreEqual(1, reviews.Count(r => r.AuthorId == token));
        }