public void UpdateCoursesOrders_WhenCalled_UpdateCoursesOrders()
        {
            // Arrange
            var course1 = new LearningPathCourse("learningPathId", "course1", 1);
            var course2 = new LearningPathCourse("learningPathId", "course2", 2);
            var coursesToUpdateOrders = new List <LearningPathCourse> {
                course1, course2
            };

            var coursesNewOrders = new[]
            {
                new CourseOrderDto {
                    CourseId = course1.CourseId, Order = 2
                },
                new CourseOrderDto {
                    CourseId = course2.CourseId, Order = 1
                }
            };

            // Act
            _sut.UpdateCoursesOrders(coursesToUpdateOrders, coursesNewOrders);

            // Assert
            Assert.That(course1.Order, Is.EqualTo(2));
            Assert.That(course2.Order, Is.EqualTo(1));
        }
Beispiel #2
0
        public void AddLearningPath_WhenCalled_AddTheLearningPathToTheCourseLearningPathsList()
        {
            var learningPath = new LearningPathCourse("learningPathId", "courseId", 1);

            _sut.AddLearningPath(learningPath);

            Assert.That(_sut.CourseLearningPaths, Has.Member(learningPath));
        }
        public void RemoveLearningPathCourseFromRepo_WhenCalled_RemoveLearningPathCourseFromRepo()
        {
            var learningPathCourse = new LearningPathCourse("learningPathId", "courseId", 1);

            _sut.RemoveLearningPathCourseFromRepo(learningPathCourse);

            _repo.Verify(x => x.RemoveLearningPathCourse(learningPathCourse));
        }
Beispiel #4
0
        public void UpdateOrder_WhenCalled_UpdateCourseOrderAmongTheLearningPathCourses()
        {
            _sut = new LearningPathCourse("learningPathId", "courseId", 1);

            _sut.UpdateOrder(2);

            Assert.That(_sut.Order, Is.EqualTo(2));
        }
Beispiel #5
0
        public void ConstructorWithLearningPathIdCourseIdOrder_WhenCalled_SetRequiredPropertiesCorrectly()
        {
            _sut = new LearningPathCourse("learningPathId", "courseId", 1);

            Assert.That(_sut.LearningPathId, Is.EqualTo("learningPathId"));
            Assert.That(_sut.CourseId, Is.EqualTo("courseId"));
            Assert.That(_sut.Order, Is.EqualTo(1));
        }
Beispiel #6
0
        public void RemoveLearningPath_WhenCalled_RemoveTheLearningPathFromTheCourseLearningPathsList()
        {
            var learningPath = new LearningPathCourse("learningPathId", "courseId", 1);

            _sut.AddLearningPath(learningPath);

            _sut.RemoveLearningPath(learningPath);

            Assert.That(_sut.CourseLearningPaths, Has.No.Member(learningPath));
        }
        public void GetLearningPathCourseFromRepo_WhenCalled_ReturnLearningPathCourse()
        {
            var learningPathCourse = new LearningPathCourse("learningPathId", "courseId", 1);

            _repo.Setup(x => x.GetLearningPathCourse("learningPathId", "courseId", default))
            .ReturnsAsync(learningPathCourse);

            var result = _sut.GetLearningPathCourseFromRepo("learningPathId", "courseId", default).Result;

            Assert.That(result, Is.EqualTo(learningPathCourse));
        }
Beispiel #8
0
        public async Task AddLearningPathToCourse(Course course, string newLearningPathId,
                                                  CancellationToken token)
        {
            await CheckLearningPathExistence(newLearningPathId, token);

            var courseOrder = await _repo.GetLearningPathLastOrder(newLearningPathId, token);

            if (courseOrder != null)
            {
                var courseLearningPath = new LearningPathCourse(newLearningPathId, course.Id, courseOrder.Value + 1);
                course.AddLearningPath(courseLearningPath);
            }
        }
Beispiel #9
0
        public void SetUp()
        {
            _service    = new Mock <IRemoveCourseFromLearningPathService>();
            _unitOfWork = new Mock <IUnitOfWork>();
            _sut        = new RemoveCourseFromLearningPathCommandHandler(_service.Object, _unitOfWork.Object);

            _command = new RemoveCourseFromLearningPathCommand
            {
                LearningPathId = "learningPathId", CourseId = "courseId"
            };

            _learningPathCourseToDelete = new LearningPathCourse("learningPathId", "courseId", 1);
            _service.Setup(x => x.GetLearningPathCourseFromRepo(_command.LearningPathId, _command.CourseId, default))
            .ReturnsAsync(_learningPathCourseToDelete);
        }
        RemoveEventualLearningPaths_newLearningPathsIdsListDoesNotContainExistingLearningPaths_RemoveExistingLearningPaths()
        {
            // Arrange
            var course = new Course("title", "creatorId", DateTime.Now);
            var existingLearningPath = new LearningPathCourse("learningPathId1", "courseId", 1);

            course.AddLearningPath(existingLearningPath);

            var newCourseLearningPathsIds = new[] { "learningPathId2" };

            // Act
            _sut.RemoveEventualLearningPaths(course, newCourseLearningPathsIds);

            // Assert
            Assert.That(course.CourseLearningPaths, Has.No.Member(existingLearningPath));
        }
        public void GetLearningPathsIdsToAdd_NoNewLearningPathId_ReturnEmptyList()
        {
            // Arrange
            var course = new Course("title", "creatorId", DateTime.Now);
            var existingLearningPath = new LearningPathCourse("learningPathId1", "courseId", 1);

            course.AddLearningPath(existingLearningPath);

            var newCourseLearningPathsIds = new[] { "learningPathId1" };

            // Act
            var result = _sut.GetLearningPathsIdsToAdd(course, newCourseLearningPathsIds);

            // Assert
            Assert.That(result, Is.Empty);
        }
        public void RemoveEventualLearningPaths_newLearningPathsIdsListIsEmpty_RemoveAllExistingLearningPaths()
        {
            // Arrange
            var course = new Course("title", "creatorId", DateTime.Now);
            var existingLearningPath1 = new LearningPathCourse("learningPathId1", "courseId", 1);
            var existingLearningPath2 = new LearningPathCourse("learningPathId2", "courseId", 2);

            course.AddLearningPath(existingLearningPath1);
            course.AddLearningPath(existingLearningPath2);

            var newCourseLearningPathsIds = new List <string>();

            // Act
            _sut.RemoveEventualLearningPaths(course, newCourseLearningPathsIds);

            // Assert
            Assert.That(course.CourseLearningPaths, Is.Empty);
        }
Beispiel #13
0
 public void RemoveLearningPathCourseFromRepo(LearningPathCourse learningPathCourse)
 {
     _repo.RemoveLearningPathCourse(learningPathCourse);
 }
Beispiel #14
0
 public void RemoveLearningPathCourse(LearningPathCourse learningPathCourse)
 {
     _context.LearningPathCourses.Remove(learningPathCourse);
 }