public void TestCollectionItemIdentifierWithDuplicates()
        {
            var container = new AssetPropertyGraphContainer(new PackageSession(), new AssetNodeContainer {
                NodeBuilder = { ContentFactory = new AssetNodeFactory() }
            });
            var asset = new Types.MyAsset2 {
                MyStrings = { "aaa", "bbb", "ccc" }
            };
            var ids = CollectionItemIdHelper.GetCollectionItemIds(asset.MyStrings);

            ids.Add(0, IdentifierGenerator.Get(100));
            ids.Add(1, IdentifierGenerator.Get(200));
            ids.Add(2, IdentifierGenerator.Get(100));
            var assetItem = new AssetItem("MyAsset", asset);

            Assert.AreEqual(IdentifierGenerator.Get(100), ids[0]);
            Assert.AreEqual(IdentifierGenerator.Get(200), ids[1]);
            Assert.AreEqual(IdentifierGenerator.Get(100), ids[2]);
            var graph = AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null);

            Assert.IsAssignableFrom <AssetObjectNode>(graph.RootNode);
            Assert.True(CollectionItemIdHelper.TryGetCollectionItemIds(asset.MyStrings, out ids));
            Assert.AreEqual(3, ids.KeyCount);
            Assert.AreEqual(0, ids.DeletedCount);
            Assert.AreEqual(IdentifierGenerator.Get(100), ids[0]);
            Assert.AreEqual(IdentifierGenerator.Get(200), ids[1]);
            Assert.AreNotEqual(IdentifierGenerator.Get(100), ids[2]);
            Assert.AreNotEqual(IdentifierGenerator.Get(200), ids[2]);
        }
Ejemplo n.º 2
0
        public void TestSimpleCollectionAddMultipleAndCheckOrder()
        {
            var asset = new Types.MyAsset2 {
                MyStrings = { "String1", "String2", "String3", "String4" }
            };
            var context = DeriveAssetTest <Types.MyAsset2> .DeriveAsset(asset);

            var baseIds             = CollectionItemIdHelper.GetCollectionItemIds(context.BaseAsset.MyStrings);
            var derivedIds          = CollectionItemIdHelper.GetCollectionItemIds(context.DerivedAsset.MyStrings);
            var basePropertyNode    = (AssetNode)((IGraphNode)context.BaseGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));
            var derivedPropertyNode = (AssetNode)((IGraphNode)context.DerivedGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));

            derivedPropertyNode.Content.Add("String3.5", new Index(3));
            derivedPropertyNode.Content.Add("String1.5", new Index(1));
            Assert.AreEqual(6, context.DerivedAsset.MyStrings.Count);
            AssertCollection(derivedPropertyNode.Content, "String1", "String1.5", "String2", "String3", "String3.5", "String4");

            basePropertyNode.Content.Add("String0.1", new Index(0));
            Assert.AreEqual(5, context.BaseAsset.MyStrings.Count);
            AssertCollection(basePropertyNode.Content, "String0.1", "String1", "String2", "String3", "String4");
            Assert.AreEqual(7, context.DerivedAsset.MyStrings.Count);
            AssertCollection(derivedPropertyNode.Content, "String0.1", "String1", "String1.5", "String2", "String3", "String3.5", "String4");

            basePropertyNode.Content.Add("String1.1", new Index(2));
            Assert.AreEqual(6, context.BaseAsset.MyStrings.Count);
            AssertCollection(basePropertyNode.Content, "String0.1", "String1", "String1.1", "String2", "String3", "String4");
            Assert.AreEqual(8, context.DerivedAsset.MyStrings.Count);
            AssertCollection(derivedPropertyNode.Content, "String0.1", "String1", "String1.1", "String1.5", "String2", "String3", "String3.5", "String4");

            basePropertyNode.Content.Add("String2.1", new Index(4));
            Assert.AreEqual(7, context.BaseAsset.MyStrings.Count);
            AssertCollection(basePropertyNode.Content, "String0.1", "String1", "String1.1", "String2", "String2.1", "String3", "String4");
            Assert.AreEqual(9, context.DerivedAsset.MyStrings.Count);
            AssertCollection(derivedPropertyNode.Content, "String0.1", "String1", "String1.1", "String1.5", "String2", "String2.1", "String3", "String3.5", "String4");

            basePropertyNode.Content.Add("String3.1", new Index(6));
            Assert.AreEqual(8, context.BaseAsset.MyStrings.Count);
            AssertCollection(basePropertyNode.Content, "String0.1", "String1", "String1.1", "String2", "String2.1", "String3", "String3.1", "String4");
            Assert.AreEqual(10, context.DerivedAsset.MyStrings.Count);
            AssertCollection(derivedPropertyNode.Content, "String0.1", "String1", "String1.1", "String1.5", "String2", "String2.1", "String3", "String3.1", "String3.5", "String4");

            basePropertyNode.Content.Add("String4.1", new Index(8));
            Assert.AreEqual(9, context.BaseAsset.MyStrings.Count);
            AssertCollection(basePropertyNode.Content, "String0.1", "String1", "String1.1", "String2", "String2.1", "String3", "String3.1", "String4", "String4.1");
            Assert.AreEqual(11, context.DerivedAsset.MyStrings.Count);
            AssertCollection(derivedPropertyNode.Content, "String0.1", "String1", "String1.1", "String1.5", "String2", "String2.1", "String3", "String3.1", "String3.5", "String4", "String4.1");

            Assert.AreEqual(9, baseIds.Count);
            Assert.AreEqual(11, derivedIds.Count);
            Assert.AreEqual(baseIds[0], derivedIds[0]);
            Assert.AreEqual(baseIds[1], derivedIds[1]);
            Assert.AreEqual(baseIds[2], derivedIds[2]);
            Assert.AreEqual(baseIds[3], derivedIds[4]);
            Assert.AreEqual(baseIds[4], derivedIds[5]);
            Assert.AreEqual(baseIds[5], derivedIds[6]);
            Assert.AreEqual(baseIds[6], derivedIds[7]);
            Assert.AreEqual(baseIds[7], derivedIds[9]);
            Assert.AreEqual(baseIds[8], derivedIds[10]);
        }
 public void TestSimpleCollectionUpdate()
 {
     var container = new AssetPropertyGraphContainer(new PackageSession(), new AssetNodeContainer());
     var asset = new Types.MyAsset2 { MyStrings = { "aaa", "bbb", "ccc" } };
     var assetItem = new AssetItem("MyAsset", asset);
     var graph = AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null);
     var node = ((IGraphNode)graph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));
     //var ids = CollectionItemIdHelper.TryGetCollectionItemIds(asset.MyStrings, out itemIds);
 }
Ejemplo n.º 4
0
 public void TestSimpleCollectionUpdate()
 {
     var container = new AssetPropertyGraphContainer(new PackageSession(), new AssetNodeContainer());
     var asset     = new Types.MyAsset2 {
         MyStrings = { "aaa", "bbb", "ccc" }
     };
     var assetItem = new AssetItem("MyAsset", asset);
     var graph     = AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null);
     var node      = ((IGraphNode)graph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));
     //var ids = CollectionItemIdHelper.TryGetCollectionItemIds(asset.MyStrings, out itemIds);
 }
 public void TestCollectionConstruction()
 {
     var container = new AssetPropertyGraphContainer(new PackageSession(), new AssetNodeContainer());
     var asset = new Types.MyAsset2 { MyStrings = { "aaa", "bbb", "ccc" } };
     var assetItem = new AssetItem("MyAsset", asset);
     var graph = AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null);
     Assert.IsAssignableFrom<AssetNode>(graph.RootNode);
     CollectionItemIdentifiers ids;
     Assert.True(CollectionItemIdHelper.TryGetCollectionItemIds(asset.MyStrings, out ids));
     Assert.AreEqual(3, ids.KeyCount);
     Assert.AreEqual(0, ids.DeletedCount);
     Assert.True(ids.ContainsKey(0));
     Assert.True(ids.ContainsKey(1));
     Assert.True(ids.ContainsKey(2));
 }
Ejemplo n.º 6
0
        public void TestSimpleCollectionRemoveDeleted()
        {
            var asset = new Types.MyAsset2 {
                MyStrings = { "String1", "String2", "String3", "String4" }
            };
            var context = DeriveAssetTest <Types.MyAsset2> .DeriveAsset(asset);

            var baseIds             = CollectionItemIdHelper.GetCollectionItemIds(context.BaseAsset.MyStrings);
            var derivedIds          = CollectionItemIdHelper.GetCollectionItemIds(context.DerivedAsset.MyStrings);
            var basePropertyNode    = (AssetNode)((IGraphNode)context.BaseGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));
            var derivedPropertyNode = (AssetNode)((IGraphNode)context.DerivedGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));

            // Delete an item from the derived and then delete the same from the base
            var derivedDeletedId = derivedIds[2];
            var baseDeletedId    = baseIds[2];

            derivedPropertyNode.Content.Remove("String3", new Index(2));
            basePropertyNode.Content.Remove("String3", new Index(2));
            Assert.AreEqual(3, context.BaseAsset.MyStrings.Count);
            Assert.AreEqual(3, context.DerivedAsset.MyStrings.Count);
            Assert.AreEqual("String1", basePropertyNode.Content.Retrieve(new Index(0)));
            Assert.AreEqual("String2", basePropertyNode.Content.Retrieve(new Index(1)));
            Assert.AreEqual("String4", basePropertyNode.Content.Retrieve(new Index(2)));
            Assert.AreEqual("String1", derivedPropertyNode.Content.Retrieve(new Index(0)));
            Assert.AreEqual("String2", derivedPropertyNode.Content.Retrieve(new Index(1)));
            Assert.AreEqual("String4", derivedPropertyNode.Content.Retrieve(new Index(2)));
            Assert.AreEqual(OverrideType.Base, basePropertyNode.GetContentOverride());
            Assert.AreEqual(OverrideType.Base, basePropertyNode.GetItemOverride(new Index(0)));
            Assert.AreEqual(OverrideType.Base, basePropertyNode.GetItemOverride(new Index(1)));
            Assert.AreEqual(OverrideType.Base, basePropertyNode.GetItemOverride(new Index(2)));
            Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetContentOverride());
            Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetItemOverride(new Index(0)));
            Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetItemOverride(new Index(1)));
            Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetItemOverride(new Index(2)));
            Assert.AreEqual(3, baseIds.Count);
            Assert.AreEqual(3, baseIds.KeyCount);
            Assert.AreEqual(0, baseIds.DeletedCount);
            Assert.AreEqual(3, derivedIds.Count);
            Assert.AreEqual(3, derivedIds.KeyCount);
            Assert.AreEqual(0, derivedIds.DeletedCount);
            Assert.AreEqual(baseIds[0], derivedIds[0]);
            Assert.AreEqual(baseIds[1], derivedIds[1]);
            Assert.AreEqual(baseIds[2], derivedIds[2]);
            Assert.False(derivedIds.IsDeleted(derivedDeletedId));
            Assert.False(baseIds.IsDeleted(baseDeletedId));
        }
Ejemplo n.º 7
0
        public void TestCollectionConstruction()
        {
            var container = new AssetPropertyGraphContainer(new PackageSession(), new AssetNodeContainer());
            var asset     = new Types.MyAsset2 {
                MyStrings = { "aaa", "bbb", "ccc" }
            };
            var assetItem = new AssetItem("MyAsset", asset);
            var graph     = AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null);

            Assert.IsAssignableFrom <AssetNode>(graph.RootNode);
            CollectionItemIdentifiers ids;

            Assert.True(CollectionItemIdHelper.TryGetCollectionItemIds(asset.MyStrings, out ids));
            Assert.AreEqual(3, ids.KeyCount);
            Assert.AreEqual(0, ids.DeletedCount);
            Assert.True(ids.ContainsKey(0));
            Assert.True(ids.ContainsKey(1));
            Assert.True(ids.ContainsKey(2));
        }
        public void TestSimpleCollectionRemoveDeleted()
        {
            var asset = new Types.MyAsset2 { MyStrings = { "String1", "String2", "String3", "String4" } };
            var context = DeriveAssetTest<Types.MyAsset2>.DeriveAsset(asset);
            var baseIds = CollectionItemIdHelper.GetCollectionItemIds(context.BaseAsset.MyStrings);
            var derivedIds = CollectionItemIdHelper.GetCollectionItemIds(context.DerivedAsset.MyStrings);
            var basePropertyNode = (AssetNode)((IGraphNode)context.BaseGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));
            var derivedPropertyNode = (AssetNode)((IGraphNode)context.DerivedGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));

            // Delete an item from the derived and then delete the same from the base
            var derivedDeletedId = derivedIds[2];
            var baseDeletedId = baseIds[2];
            derivedPropertyNode.Content.Remove("String3", new Index(2));
            basePropertyNode.Content.Remove("String3", new Index(2));
            Assert.AreEqual(3, context.BaseAsset.MyStrings.Count);
            Assert.AreEqual(3, context.DerivedAsset.MyStrings.Count);
            Assert.AreEqual("String1", basePropertyNode.Content.Retrieve(new Index(0)));
            Assert.AreEqual("String2", basePropertyNode.Content.Retrieve(new Index(1)));
            Assert.AreEqual("String4", basePropertyNode.Content.Retrieve(new Index(2)));
            Assert.AreEqual("String1", derivedPropertyNode.Content.Retrieve(new Index(0)));
            Assert.AreEqual("String2", derivedPropertyNode.Content.Retrieve(new Index(1)));
            Assert.AreEqual("String4", derivedPropertyNode.Content.Retrieve(new Index(2)));
            Assert.AreEqual(OverrideType.Base, basePropertyNode.GetContentOverride());
            Assert.AreEqual(OverrideType.Base, basePropertyNode.GetItemOverride(new Index(0)));
            Assert.AreEqual(OverrideType.Base, basePropertyNode.GetItemOverride(new Index(1)));
            Assert.AreEqual(OverrideType.Base, basePropertyNode.GetItemOverride(new Index(2)));
            Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetContentOverride());
            Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetItemOverride(new Index(0)));
            Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetItemOverride(new Index(1)));
            Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetItemOverride(new Index(2)));
            Assert.AreEqual(3, baseIds.KeyCount);
            Assert.AreEqual(0, baseIds.DeletedCount);
            Assert.AreEqual(3, derivedIds.KeyCount);
            Assert.AreEqual(0, derivedIds.DeletedCount);
            Assert.AreEqual(baseIds[0], derivedIds[0]);
            Assert.AreEqual(baseIds[1], derivedIds[1]);
            Assert.AreEqual(baseIds[2], derivedIds[2]);
            Assert.False(derivedIds.IsDeleted(derivedDeletedId));
            Assert.False(baseIds.IsDeleted(baseDeletedId));
        }
 public void TestCollectionItemIdentifierWithDuplicates()
 {
     var container = new AssetPropertyGraphContainer(new PackageSession(), new AssetNodeContainer());
     var asset = new Types.MyAsset2 { MyStrings = { "aaa", "bbb", "ccc" } };
     var ids = CollectionItemIdHelper.GetCollectionItemIds(asset.MyStrings);
     ids.Add(0, IdentifierGenerator.Get(100));
     ids.Add(1, IdentifierGenerator.Get(200));
     ids.Add(2, IdentifierGenerator.Get(100));
     var assetItem = new AssetItem("MyAsset", asset);
     Assert.AreEqual(IdentifierGenerator.Get(100), ids[0]);
     Assert.AreEqual(IdentifierGenerator.Get(200), ids[1]);
     Assert.AreEqual(IdentifierGenerator.Get(100), ids[2]);
     var graph = AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null);
     Assert.IsAssignableFrom<AssetNode>(graph.RootNode);
     Assert.True(CollectionItemIdHelper.TryGetCollectionItemIds(asset.MyStrings, out ids));
     Assert.AreEqual(3, ids.KeyCount);
     Assert.AreEqual(0, ids.DeletedCount);
     Assert.AreEqual(IdentifierGenerator.Get(100), ids[0]);
     Assert.AreEqual(IdentifierGenerator.Get(200), ids[1]);
     Assert.AreNotEqual(IdentifierGenerator.Get(100), ids[2]);
     Assert.AreNotEqual(IdentifierGenerator.Get(200), ids[2]);
 }
        public static TestArchetypesRun PrepareSimpleCollectionUpdate()
        {
            var asset = new Types.MyAsset2 { MyStrings = { "String1", "String2" } };
            var context = DeriveAssetTest<Types.MyAsset2>.DeriveAsset(asset);
            var baseIds = CollectionItemIdHelper.GetCollectionItemIds(asset.MyStrings);
            var derivedIds = CollectionItemIdHelper.GetCollectionItemIds(context.DerivedAsset.MyStrings);
            var basePropertyNode = (AssetNode)((IGraphNode)context.BaseGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));
            var derivedPropertyNode = (AssetNode)((IGraphNode)context.DerivedGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));

            var test = new TestArchetypesRun(context)
            {
                InitialCheck = () =>
                {
                    Assert.AreEqual(2, context.BaseAsset.MyStrings.Count);
                    Assert.AreEqual(2, context.DerivedAsset.MyStrings.Count);
                    Assert.AreEqual("String1", basePropertyNode.Content.Retrieve(new Index(0)));
                    Assert.AreEqual("String2", basePropertyNode.Content.Retrieve(new Index(1)));
                    Assert.AreEqual("String1", derivedPropertyNode.Content.Retrieve(new Index(0)));
                    Assert.AreEqual("String2", derivedPropertyNode.Content.Retrieve(new Index(1)));
                    Assert.AreEqual(OverrideType.Base, basePropertyNode.GetContentOverride());
                    Assert.AreEqual(OverrideType.Base, basePropertyNode.GetItemOverride(new Index(0)));
                    Assert.AreEqual(OverrideType.Base, basePropertyNode.GetItemOverride(new Index(1)));
                    Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetContentOverride());
                    Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetItemOverride(new Index(0)));
                    Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetItemOverride(new Index(1)));
                    Assert.AreEqual(0, derivedPropertyNode.GetOverriddenItemIndices().Count());
                    Assert.AreEqual(0, derivedPropertyNode.GetOverriddenKeyIndices().Count());
                    Assert.AreNotSame(baseIds, derivedIds);
                    Assert.AreEqual(2, baseIds.KeyCount);
                    Assert.AreEqual(0, baseIds.DeletedCount);
                    Assert.AreEqual(2, derivedIds.KeyCount);
                    Assert.AreEqual(0, derivedIds.DeletedCount);
                    Assert.AreEqual(baseIds[0], derivedIds[0]);
                    Assert.AreEqual(baseIds[1], derivedIds[1]);
                },
                FirstChange = () =>
                {
                    basePropertyNode.Content.Update("MyBaseString", new Index(1));
                },
                FirstChangeCheck = () =>
                {
                    Assert.AreEqual(2, context.BaseAsset.MyStrings.Count);
                    Assert.AreEqual(2, context.DerivedAsset.MyStrings.Count);
                    Assert.AreEqual("String1", basePropertyNode.Content.Retrieve(new Index(0)));
                    Assert.AreEqual("MyBaseString", basePropertyNode.Content.Retrieve(new Index(1)));
                    Assert.AreEqual("String1", derivedPropertyNode.Content.Retrieve(new Index(0)));
                    Assert.AreEqual("MyBaseString", derivedPropertyNode.Content.Retrieve(new Index(1)));
                    Assert.AreEqual(OverrideType.Base, basePropertyNode.GetContentOverride());
                    Assert.AreEqual(OverrideType.Base, basePropertyNode.GetItemOverride(new Index(0)));
                    Assert.AreEqual(OverrideType.Base, basePropertyNode.GetItemOverride(new Index(1)));
                    Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetContentOverride());
                    Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetItemOverride(new Index(0)));
                    Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetItemOverride(new Index(1)));
                    Assert.AreEqual(0, derivedPropertyNode.GetOverriddenItemIndices().Count());
                    Assert.AreEqual(0, derivedPropertyNode.GetOverriddenKeyIndices().Count());
                    Assert.AreNotSame(baseIds, derivedIds);
                    Assert.AreEqual(2, baseIds.KeyCount);
                    Assert.AreEqual(0, baseIds.DeletedCount);
                    Assert.AreEqual(2, derivedIds.KeyCount);
                    Assert.AreEqual(0, derivedIds.DeletedCount);
                    Assert.AreEqual(baseIds[0], derivedIds[0]);
                    Assert.AreEqual(baseIds[1], derivedIds[1]);
                },
                SecondChange = () =>
                {
                    derivedPropertyNode.Content.Update("MyDerivedString", new Index(0));
                },
                SecondChangeCheck = () =>
                {
                    Assert.AreEqual(2, context.BaseAsset.MyStrings.Count);
                    Assert.AreEqual(2, context.DerivedAsset.MyStrings.Count);
                    Assert.AreEqual("String1", basePropertyNode.Content.Retrieve(new Index(0)));
                    Assert.AreEqual("MyBaseString", basePropertyNode.Content.Retrieve(new Index(1)));
                    Assert.AreEqual("MyDerivedString", derivedPropertyNode.Content.Retrieve(new Index(0)));
                    Assert.AreEqual("MyBaseString", derivedPropertyNode.Content.Retrieve(new Index(1)));
                    Assert.AreEqual(OverrideType.Base, basePropertyNode.GetContentOverride());
                    Assert.AreEqual(OverrideType.Base, basePropertyNode.GetItemOverride(new Index(0)));
                    Assert.AreEqual(OverrideType.Base, basePropertyNode.GetItemOverride(new Index(1)));
                    Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetContentOverride());
                    Assert.AreEqual(OverrideType.New, derivedPropertyNode.GetItemOverride(new Index(0)));
                    Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetItemOverride(new Index(1)));
                    Assert.AreEqual(1, derivedPropertyNode.GetOverriddenItemIndices().Count());
                    Assert.AreEqual(0, derivedPropertyNode.GetOverriddenKeyIndices().Count());
                    Assert.AreNotSame(baseIds, derivedIds);
                    Assert.AreEqual(2, baseIds.KeyCount);
                    Assert.AreEqual(0, baseIds.DeletedCount);
                    Assert.AreEqual(2, derivedIds.KeyCount);
                    Assert.AreEqual(0, derivedIds.DeletedCount);
                    Assert.AreEqual(baseIds[0], derivedIds[0]);
                    Assert.AreEqual(baseIds[1], derivedIds[1]);
                }
            };
            return test;
        }
        public void TestSimpleCollectionAddMultipleAndCheckOrder()
        {
            var asset = new Types.MyAsset2 { MyStrings = { "String1", "String2", "String3", "String4" } };
            var context = DeriveAssetTest<Types.MyAsset2>.DeriveAsset(asset);
            var baseIds = CollectionItemIdHelper.GetCollectionItemIds(context.BaseAsset.MyStrings);
            var derivedIds = CollectionItemIdHelper.GetCollectionItemIds(context.DerivedAsset.MyStrings);
            var basePropertyNode = (AssetNode)((IGraphNode)context.BaseGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));
            var derivedPropertyNode = (AssetNode)((IGraphNode)context.DerivedGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));

            derivedPropertyNode.Content.Add("String3.5", new Index(3));
            derivedPropertyNode.Content.Add("String1.5", new Index(1));
            Assert.AreEqual(6, context.DerivedAsset.MyStrings.Count);
            AssertCollection(derivedPropertyNode.Content, "String1", "String1.5", "String2", "String3", "String3.5", "String4");

            basePropertyNode.Content.Add("String0.1", new Index(0));
            Assert.AreEqual(5, context.BaseAsset.MyStrings.Count);
            AssertCollection(basePropertyNode.Content, "String0.1", "String1", "String2", "String3", "String4");
            Assert.AreEqual(7, context.DerivedAsset.MyStrings.Count);
            AssertCollection(derivedPropertyNode.Content, "String0.1", "String1", "String1.5", "String2", "String3", "String3.5", "String4");

            basePropertyNode.Content.Add("String1.1", new Index(2));
            Assert.AreEqual(6, context.BaseAsset.MyStrings.Count);
            AssertCollection(basePropertyNode.Content, "String0.1", "String1", "String1.1", "String2", "String3", "String4");
            Assert.AreEqual(8, context.DerivedAsset.MyStrings.Count);
            AssertCollection(derivedPropertyNode.Content, "String0.1", "String1", "String1.1", "String1.5", "String2", "String3", "String3.5", "String4");

            basePropertyNode.Content.Add("String2.1", new Index(4));
            Assert.AreEqual(7, context.BaseAsset.MyStrings.Count);
            AssertCollection(basePropertyNode.Content, "String0.1", "String1", "String1.1", "String2", "String2.1", "String3", "String4");
            Assert.AreEqual(9, context.DerivedAsset.MyStrings.Count);
            AssertCollection(derivedPropertyNode.Content, "String0.1", "String1", "String1.1", "String1.5", "String2", "String2.1", "String3", "String3.5", "String4");

            basePropertyNode.Content.Add("String3.1", new Index(6));
            Assert.AreEqual(8, context.BaseAsset.MyStrings.Count);
            AssertCollection(basePropertyNode.Content, "String0.1", "String1", "String1.1", "String2", "String2.1", "String3", "String3.1", "String4");
            Assert.AreEqual(10, context.DerivedAsset.MyStrings.Count);
            AssertCollection(derivedPropertyNode.Content, "String0.1", "String1", "String1.1", "String1.5", "String2", "String2.1", "String3", "String3.1", "String3.5", "String4");

            basePropertyNode.Content.Add("String4.1", new Index(8));
            Assert.AreEqual(9, context.BaseAsset.MyStrings.Count);
            AssertCollection(basePropertyNode.Content, "String0.1", "String1", "String1.1", "String2", "String2.1", "String3", "String3.1", "String4", "String4.1");
            Assert.AreEqual(11, context.DerivedAsset.MyStrings.Count);
            AssertCollection(derivedPropertyNode.Content, "String0.1", "String1", "String1.1", "String1.5", "String2", "String2.1", "String3", "String3.1", "String3.5", "String4", "String4.1");

            Assert.AreEqual(9, baseIds.KeyCount);
            Assert.AreEqual(0, baseIds.DeletedCount);
            Assert.AreEqual(11, derivedIds.KeyCount);
            Assert.AreEqual(0, derivedIds.DeletedCount);
            Assert.AreEqual(baseIds[0], derivedIds[0]);
            Assert.AreEqual(baseIds[1], derivedIds[1]);
            Assert.AreEqual(baseIds[2], derivedIds[2]);
            Assert.AreEqual(baseIds[3], derivedIds[4]);
            Assert.AreEqual(baseIds[4], derivedIds[5]);
            Assert.AreEqual(baseIds[5], derivedIds[6]);
            Assert.AreEqual(baseIds[6], derivedIds[7]);
            Assert.AreEqual(baseIds[7], derivedIds[9]);
            Assert.AreEqual(baseIds[8], derivedIds[10]);
        }
        public void TestSimpleCollectionAddSerialization()
        {
            var asset = new Types.MyAsset2 { MyStrings = { "String1", "String2" } };
            var baseIds = CollectionItemIdHelper.GetCollectionItemIds(asset.MyStrings);
            baseIds.Add(0, IdentifierGenerator.Get(10));
            baseIds.Add(1, IdentifierGenerator.Get(20));
            var context = DeriveAssetTest<Types.MyAsset2>.DeriveAsset(asset);
            var basePropertyNode = (AssetNode)((IGraphNode)context.BaseGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));
            var derivedPropertyNode = (AssetNode)((IGraphNode)context.DerivedGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));

            derivedPropertyNode.Content.Add("String3");
            basePropertyNode.Content.Add("String4");
            var derivedIds = CollectionItemIdHelper.GetCollectionItemIds(context.DerivedAsset.MyStrings);
            var expectedBaseYaml = string.Format(SimpleCollectionAddBaseYaml.Replace("{}", "{{}}"), baseIds[2]);
            var expectedDerivedYaml = string.Format(SimpleCollectionAddDerivedYaml.Replace("{}", "{{}}"), baseIds[2], derivedIds[3]);
            SerializeAndCompare(context.BaseAssetItem, context.BaseGraph, expectedBaseYaml, false);
            SerializeAndCompare(context.DerivedAssetItem, context.DerivedGraph, expectedDerivedYaml, true);
        }
        public void TestCollectionInStructUpdateSerialization()
        {
            var asset = new Types.MyAsset2();
            asset.Struct.MyStrings.Add("String1");
            asset.Struct.MyStrings.Add("String2");
            var ids = CollectionItemIdHelper.GetCollectionItemIds(asset.Struct.MyStrings);
            ids.Add(0, IdentifierGenerator.Get(10));
            ids.Add(1, IdentifierGenerator.Get(20));
            var context = DeriveAssetTest<Types.MyAsset2>.DeriveAsset(asset);
            var basePropertyNode = (AssetNode)((IGraphNode)context.BaseGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.Struct)).TryGetChild(nameof(Types.MyAsset2.MyStrings));
            var derivedPropertyNode = (AssetNode)((IGraphNode)context.DerivedGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.Struct)).TryGetChild(nameof(Types.MyAsset2.MyStrings));

            basePropertyNode.Content.Update("MyBaseString", new Index(1));
            derivedPropertyNode.Content.Update("MyDerivedString", new Index(0));
            SerializeAndCompare(context.BaseAssetItem, context.BaseGraph, CollectionInStructBaseYaml, false);
            SerializeAndCompare(context.DerivedAssetItem, context.DerivedGraph, CollectionInStructDerivedYaml, true);
        }