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 Insert_NewProfileAdded()
        {
            // Arrange
            IDataMapper <CourseProfile> dataMapper = new ProfileJsonDataMapper(_profilePath);
            CourseProfile profile = new CourseProfile
            {
                Name = "FrondEnd_Developer"
            };

            // Act
            dataMapper.Insert(profile);

            // Assert
            var result = dataMapper.FindAll();

            Assert.AreEqual(4, result.Count());
            Assert.AreEqual("NET_Developer", result.ElementAt(0).Name);
            Assert.AreEqual(31, result.ElementAt(0).Courses.Count());
            Assert.AreEqual("Developer_Mobile", result.ElementAt(1).Name);
            Assert.AreEqual(30, result.ElementAt(1).Courses.Count());
            Assert.AreEqual("JAVA_Developer", result.ElementAt(2).Name);
            Assert.AreEqual(27, result.ElementAt(2).Courses.Count());
            Assert.AreEqual("FrondEnd_Developer", result.ElementAt(3).Name);
            Assert.AreEqual(0, result.ElementAt(3).Courses.Count());
            Assert.AreEqual(4, result.ElementAt(3).Id);
        }
        public void FindAll_ThreeProfilesFound()
        {
            // Arrange
            IDataMapper <CourseProfile> dataMapper = new ProfileJsonDataMapper(_profilePath);

            // Act
            var result = dataMapper.FindAll();

            // Assert
            Assert.AreEqual(3, result.Count());
        }
        public void Delete_ProfileDeleted()
        {
            // Arrange
            IDataMapper <CourseProfile> dataMapper = new ProfileJsonDataMapper(_profilePath);

            // Act
            dataMapper.Delete(1);

            // Assert
            var result = dataMapper.FindAll();

            Assert.AreEqual(2, result.Count());
            Assert.AreEqual("Developer_Mobile", result.ElementAt(0).Name);
            Assert.AreEqual(30, result.ElementAt(0).Courses.Count());
            Assert.AreEqual("JAVA_Developer", result.ElementAt(1).Name);
            Assert.AreEqual(27, result.ElementAt(1).Courses.Count());
        }
        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());
        }
        public void Update_ProfileUpdated()
        {
            // Arrange
            IDataMapper <CourseProfile> dataMapper = new ProfileJsonDataMapper(_profilePath);
            CourseProfile profile = new CourseProfile
            {
                Id   = 1,
                Name = "DOT_NET_Developer"
            };

            // Act
            dataMapper.Update(profile);

            // Assert
            var result = dataMapper.FindAll();

            Assert.AreEqual(3, result.Count());
            Assert.AreEqual("DOT_NET_Developer", result.ElementAt(0).Name);
            Assert.AreEqual(31, result.ElementAt(0).Courses.Count());
            Assert.AreEqual("Developer_Mobile", result.ElementAt(1).Name);
            Assert.AreEqual(30, result.ElementAt(1).Courses.Count());
            Assert.AreEqual("JAVA_Developer", result.ElementAt(2).Name);
            Assert.AreEqual(27, result.ElementAt(2).Courses.Count());
        }