public void RemoveRange_WhenCalled_RemoveListOfCoursesFromList()
        {
            //Arrange
            List <Course> coursesToRemove = new List <Course>()
            {
                new Course()
                {
                    Name = "Italian club", CourseTypeId = internalCT.Id, IsDeleted = false
                },
                new Course()
                {
                    Name = "Spanish club", CourseTypeId = internalCT.Id, IsDeleted = false
                }
            };

            var cToRemove1Id = coursesToRemove[0].Id;
            var cToRemove2Id = coursesToRemove[1].Id;

            courseRepository.AddRange(coursesToRemove);

            //Act
            courseRepository.RemoveRange(coursesToRemove);

            var courseIds = courseRepository.GetAll().Select(c => c.Id).ToList();

            //Assert
            Assert.That(courseIds, Does.Not.Contain(cToRemove1Id));
            Assert.That(courseIds, Does.Not.Contain(cToRemove2Id));
        }
Esempio n. 2
0
 public void AddCourses(IEnumerable <Course> courses)
 {
     using (TransactionScope tran = new TransactionScope()) {
         Courses.AddRange(courses);
         //Complete();
         tran.Complete();
     }
 }
Esempio n. 3
0
        public void AddRange(IEnumerable <Course> courses)
        {
            foreach (var c in courses)
            {
                ValidateCourse(c);
                ValidateDuplicatedCourse(c);

                c.IsDeleted = false;
            }

            _courseRepository.AddRange(courses);
        }