public void TestSimpleConstruction()
 {
     var container = new AssetPropertyGraphContainer(new PackageSession(), new AssetNodeContainer());
     var asset = new Types.MyAsset1 { MyString = "String" };
     var assetItem = new AssetItem("MyAsset", asset);
     var graph = AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null);
     Assert.IsAssignableFrom<AssetNode>(graph.RootNode);
 }
Beispiel #2
0
        public void TestSimpleConstruction()
        {
            var container = new AssetPropertyGraphContainer(new PackageSession(), new AssetNodeContainer());
            var asset     = new Types.MyAsset1 {
                MyString = "String"
            };
            var assetItem = new AssetItem("MyAsset", asset);
            var graph     = AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null);

            Assert.IsAssignableFrom <AssetNode>(graph.RootNode);
        }
        public static TestArchetypesRun PrepareSimplePropertyChange()
        {
            var asset = new Types.MyAsset1 { MyString = "String" };
            var context = DeriveAssetTest<Types.MyAsset1>.DeriveAsset(asset);
            var basePropertyNode = (AssetNode)((IGraphNode)context.BaseGraph.RootNode).TryGetChild(nameof(Types.MyAsset1.MyString));
            var derivedPropertyNode = (AssetNode)((IGraphNode)context.DerivedGraph.RootNode).TryGetChild(nameof(Types.MyAsset1.MyString));

            var test = new TestArchetypesRun(context)
            {
                InitialCheck = () =>
                {
                    // Initial checks
                    Assert.AreEqual("String", basePropertyNode.Content.Retrieve());
                    Assert.AreEqual("String", derivedPropertyNode.Content.Retrieve());
                    Assert.AreEqual(OverrideType.Base, basePropertyNode.GetContentOverride());
                    Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetContentOverride());
                },
                FirstChange = () =>
                {
                    basePropertyNode.Content.Update("MyBaseString");
                },
                FirstChangeCheck = () =>
                {
                    Assert.AreEqual("MyBaseString", basePropertyNode.Content.Retrieve());
                    Assert.AreEqual("MyBaseString", derivedPropertyNode.Content.Retrieve());
                    Assert.AreEqual(OverrideType.Base, basePropertyNode.GetContentOverride());
                    Assert.AreEqual(OverrideType.Base, derivedPropertyNode.GetContentOverride());
                },
                SecondChange = () =>
                {
                    derivedPropertyNode.Content.Update("MyDerivedString");
                },
                SecondChangeCheck = () =>
                {
                    Assert.AreEqual("MyBaseString", basePropertyNode.Content.Retrieve());
                    Assert.AreEqual("MyDerivedString", derivedPropertyNode.Content.Retrieve());
                    Assert.AreEqual(OverrideType.Base, basePropertyNode.GetContentOverride());
                    Assert.AreEqual(OverrideType.New, derivedPropertyNode.GetContentOverride());
                }
            };
            return test;
        }
        public void TestSimplePropertySerialization()
        {
            var asset = new Types.MyAsset1 { MyString = "String" };
            var context = DeriveAssetTest<Types.MyAsset1>.DeriveAsset(asset);
            var basePropertyNode = (AssetNode)((IGraphNode)context.BaseGraph.RootNode).TryGetChild(nameof(Types.MyAsset1.MyString));
            var derivedPropertyNode = (AssetNode)((IGraphNode)context.DerivedGraph.RootNode).TryGetChild(nameof(Types.MyAsset1.MyString));

            basePropertyNode.Content.Update("MyBaseString");
            derivedPropertyNode.Content.Update("MyDerivedString");
            SerializeAndCompare(context.BaseAssetItem, context.BaseGraph, SimplePropertyUpdateBaseYaml, false);
            SerializeAndCompare(context.DerivedAssetItem, context.DerivedGraph, SimplePropertyUpdateDerivedYaml, true);

            context = DeriveAssetTest<Types.MyAsset1>.LoadFromYaml(SimplePropertyUpdateBaseYaml, SimplePropertyUpdateDerivedYaml);
            basePropertyNode = (AssetNode)((IGraphNode)context.BaseGraph.RootNode).TryGetChild(nameof(Types.MyAsset1.MyString));
            derivedPropertyNode = (AssetNode)((IGraphNode)context.DerivedGraph.RootNode).TryGetChild(nameof(Types.MyAsset1.MyString));

            Assert.AreEqual("MyBaseString", basePropertyNode.Content.Retrieve());
            Assert.AreEqual("MyDerivedString", derivedPropertyNode.Content.Retrieve());
            Assert.AreEqual(OverrideType.Base, basePropertyNode.GetContentOverride());
            Assert.AreEqual(OverrideType.New, derivedPropertyNode.GetContentOverride());
        }