public void Insert_NewCoursePriorityAdded()
        {
            // Arrange
            ICourseDataMapper dataMapper = new CourseJsonDataMapper(_profilePath);
            CoursePriority    course     = new CoursePriority
            {
                ProfileId = 1,
                Code      = "WINDOWDEV",
                Priority  = 5,
            };

            // Act
            dataMapper.Insert(course);

            // Assert
            IDataMapper <CourseProfile> dataMapperProfile = new ProfileJsonDataMapper(_profilePath);
            var profiles = dataMapperProfile.FindAll();

            Assert.AreEqual(3, profiles.Count());
            Assert.AreEqual(32, profiles.ElementAt(0).Courses.Count());
            Assert.AreEqual(30, profiles.ElementAt(1).Courses.Count());
            Assert.AreEqual(27, profiles.ElementAt(2).Courses.Count());
            Assert.AreEqual(5, profiles.ElementAt(0).Courses.First(c => c.Id == 90).Priority);
            Assert.AreEqual("WINDOWDEV", profiles.ElementAt(0).Courses.First(c => c.Id == 90).Code);
        }
        public void Update_CoursePriority()
        {
            // Arrange
            ICourseDataMapper dataMapper = new CourseJsonDataMapper(_profilePath);
            CoursePriority    course     = new CoursePriority
            {
                Id        = 1,
                ProfileId = 1,
                Code      = "WINDOWDEV",
                Priority  = 10,
            };

            // Act
            dataMapper.Update(course);

            // Assert
            IDataMapper <CourseProfile> dataMapperProfile = new ProfileJsonDataMapper(_profilePath);
            var profiles = dataMapperProfile.FindAll();

            Assert.AreEqual(3, profiles.Count());
            Assert.AreEqual(31, profiles.ElementAt(0).Courses.Count());
            Assert.AreEqual(30, profiles.ElementAt(1).Courses.Count());
            Assert.AreEqual(27, profiles.ElementAt(2).Courses.Count());
            Assert.AreEqual(10, profiles.ElementAt(0).Courses.First(c => c.Id == 1).Priority);
            Assert.AreEqual("WINDOWDEV", profiles.ElementAt(0).Courses.First(c => c.Id == 1).Code);
        }
        public void Update_DataIsNull_ExceptionThrowed()
        {
            // Arrange
            ICourseDataMapper dataMapper = new CourseJsonDataMapper(_profilePath);

            // Act
            dataMapper.Update(null);

            // Assert ArgumentNullException
        }
        public void Delete_WithNotExistingCourseInProfile_ExceptionThrowed()
        {
            // Arrange
            ICourseDataMapper dataMapper = new CourseJsonDataMapper(_profilePath);
            CoursePriority    course     = new CoursePriority
            {
                ProfileId = 1,
                Code      = "NODOTNET"
            };

            // Act
            dataMapper.Delete(course);

            // Assert ArgumentException
        }
        public void Insert_ExistingProfile_ExceptionThrowed()
        {
            // Arrange
            ICourseDataMapper dataMapper = new CourseJsonDataMapper(_profilePath);
            CoursePriority    course     = new CoursePriority
            {
                ProfileId = 1,
                Code      = "NETFOUNB",
                Priority  = 5,
            };

            // Act
            dataMapper.Insert(course);

            // Assert ArgumentException
        }
        public void Insert_WithCorruptedFile_ExceptionThrowed()
        {
            // Arrange
            ICourseDataMapper dataMapper = new CourseJsonDataMapper("../../Data/corrupted.json");
            CoursePriority    course     = new CoursePriority
            {
                ProfileId = 1,
                Code      = "WINDOWDEV",
                Priority  = 5,
            };

            // Act
            dataMapper.Insert(course);

            // Assert FileNotFoundException
        }
        public void Insert_WithNotExistingPath_ExceptionThrowed()
        {
            // Arrange
            ICourseDataMapper dataMapper = new CourseJsonDataMapper("noPath");
            CoursePriority    course     = new CoursePriority
            {
                ProfileId = 1,
                Code      = "WINDOWDEV",
                Priority  = 5,
            };

            // Act
            dataMapper.Insert(course);

            // Assert FileNotFoundException
        }
        public void Update_WithNotExistingCourse_ExceptionThrowed()
        {
            // Arrange
            ICourseDataMapper dataMapper = new CourseJsonDataMapper(_profilePath);
            CoursePriority    course     = new CoursePriority
            {
                Id        = 99,
                ProfileId = 1,
                Code      = "WINDOWDEV",
                Priority  = 10,
            };

            // Act
            dataMapper.Update(course);

            // Assert ArgumentException
        }
        public void Delete_CoursePriority()
        {
            // Arrange
            ICourseDataMapper dataMapper = new CourseJsonDataMapper(_profilePath);
            CoursePriority    course     = new CoursePriority
            {
                Id        = 1,
                ProfileId = 1,
                Code      = "WINDEV"
            };

            // Act
            dataMapper.Delete(course);

            // Assert
            IDataMapper <CourseProfile> dataMapperProfile = new ProfileJsonDataMapper(_profilePath);
            var profiles = dataMapperProfile.FindAll();

            Assert.AreEqual(3, profiles.Count());
            Assert.AreEqual(30, profiles.ElementAt(0).Courses.Count());
            Assert.AreEqual(30, profiles.ElementAt(1).Courses.Count());
            Assert.AreEqual(27, profiles.ElementAt(2).Courses.Count());
        }