public MockFamily()
 {
     var child1 = new Child("Child1") { Children = new ChangeTrackingCollection<Child>(CreateGrandChildren("Child1"), true) };
     var child2 = new Child("Child2") { Children = new ChangeTrackingCollection<Child>(CreateGrandChildren("Child2"), true) };
     var child3 = new Child("Child3") { Children = new ChangeTrackingCollection<Child>(CreateGrandChildren("Child3"), true) };
     Parent = new Parent("Parent")
         {
             Children = new ChangeTrackingCollection<Child> { child1, child2, child3 }
         };
 }
        public void HasChanges_Unchanged_Parent_With_Removed_Grandchild_Should_Return_True()
        {
            // Arrange
            var parent = new Parent("Parent")
            {
                Children = new ChangeTrackingCollection<Child>
                    {
                        new Child("Child1")
                            { 
                                Children = new ChangeTrackingCollection<Child>
                                { 
                                    new Child("Grandchild1"),
                                    new Child("Grandchild2")
                                } 
                            }, 
                        new Child("Child2")
                    }
            };
            var changeTracker = new ChangeTrackingCollection<Parent>(parent);
            parent.Children[0].Children.RemoveAt(0);

            // Act
            bool hasChanges = parent.HasChanges();

            // Assert
            Assert.True(hasChanges);
        }
        public void HasChanges_Unchanged_Parent_With_Unchanged_Children_Should_Return_False()
        {
            // Arrange
            var parent = new Parent("Parent")
            {
                Children = new ChangeTrackingCollection<Child>
                    {
                        new Child("Child1"), 
                        new Child("Child2")
                    }
            };
            var changeTracker = new ChangeTrackingCollection<Parent>(parent);

            // Act
            bool hasChanges = parent.HasChanges();

            // Assert
            Assert.False(hasChanges);
        }
        public void HasChanges_Deleted_Parent_Should_Return_True()
        {
            // Arrange
            var parent = new Parent("Parent");
            var changeTracker = new ChangeTrackingCollection<Parent>(parent);
            changeTracker.Remove(parent);

            // Act
            bool hasChanges = parent.HasChanges();

            // Assert
            Assert.True(hasChanges);
        }
        public void HasChanges_Modified_Parent_Should_Return_True()
        {
            // Arrange
            var parent = new Parent("Parent");
            var changeTracker = new ChangeTrackingCollection<Parent>(parent);
            parent.Name += "_Changed";

            // Act
            bool hasChanges = parent.HasChanges();

            // Assert
            Assert.True(hasChanges);
        }
        public void HasChanges_Unchanged_Parent_Should_Return_False()
        {
            // Arrange
            var parent = new Parent("Parent");
            var changeTracker = new ChangeTrackingCollection<Parent>(parent);

            // Act
            bool hasChanges = parent.HasChanges();

            // Assert
            Assert.False(hasChanges);
        }
        public void HasChanges_Unchanged_Parent_With_Modified_Child_Should_Return_True()
        {
            // Arrange
            var parent = new Parent("Parent")
            {
                Children = new ChangeTrackingCollection<Child>
                    {
                        new Child("Child1"), 
                        new Child("Child2")
                    }
            };
            var changeTracker = new ChangeTrackingCollection<Parent>(parent);
            parent.Children[0].Name += "_Changed";

            // Act
            bool hasChanges = parent.HasChanges();

            // Assert
            Assert.IsTrue(hasChanges);
        }