public void TestSimpleDeserialization()
        {
            var asset = AssetFileSerializer.Load <Types.MyAssetHierarchy>(AssetTestContainer.ToStream(SimpleHierarchyYaml), $"MyAsset{Types.FileExtension}");

            Assert.Equal(2, asset.Asset.Hierarchy.RootParts.Count);
            Assert.Equal(GuidGenerator.Get(2), asset.Asset.Hierarchy.RootParts[0].Id);
            Assert.Equal(GuidGenerator.Get(1), asset.Asset.Hierarchy.RootParts[1].Id);
            Assert.Equal(2, asset.Asset.Hierarchy.Parts.Count);
            Assert.True(asset.Asset.Hierarchy.Parts.ContainsKey(GuidGenerator.Get(1)));
            Assert.True(asset.Asset.Hierarchy.Parts.ContainsKey(GuidGenerator.Get(2)));
        }
        public void TestMissortedPartsDeserialization()
        {
            var asset = AssetFileSerializer.Load <Types.MyAssetHierarchy>(AssetTestContainer.ToStream(MissortedHierarchyYaml), $"MyAsset{Types.FileExtension}");

            Assert.Equal(2, asset.Asset.Hierarchy.RootParts.Count);
            Assert.Equal(GuidGenerator.Get(2), asset.Asset.Hierarchy.RootParts[0].Id);
            Assert.Equal(GuidGenerator.Get(1), asset.Asset.Hierarchy.RootParts[1].Id);
            Assert.Equal(4, asset.Asset.Hierarchy.Parts.Count);
            Assert.True(asset.Asset.Hierarchy.Parts.ContainsKey(GuidGenerator.Get(1)));
            Assert.True(asset.Asset.Hierarchy.Parts.ContainsKey(GuidGenerator.Get(2)));
            Assert.True(asset.Asset.Hierarchy.Parts.ContainsKey(GuidGenerator.Get(3)));
            Assert.True(asset.Asset.Hierarchy.Parts.ContainsKey(GuidGenerator.Get(4)));
            Assert.Single(asset.Asset.Hierarchy.Parts[GuidGenerator.Get(3)].Part.Children);
            Assert.Equal(asset.Asset.Hierarchy.Parts[GuidGenerator.Get(2)].Part, asset.Asset.Hierarchy.Parts[GuidGenerator.Get(3)].Part.Children[0]);
            Assert.Single(asset.Asset.Hierarchy.Parts[GuidGenerator.Get(4)].Part.Children);
            Assert.Equal(asset.Asset.Hierarchy.Parts[GuidGenerator.Get(1)].Part, asset.Asset.Hierarchy.Parts[GuidGenerator.Get(4)].Part.Children[0]);
        }
Exemple #3
0
        public static DeriveAssetTest <TAsset, TAssetPropertyGraph> LoadFromYaml(string baseYaml, string derivedYaml)
        {
            var container = new AssetPropertyGraphContainer(new AssetNodeContainer {
                NodeBuilder = { NodeFactory = new AssetNodeFactory() }
            });
            var baseAsset        = AssetFileSerializer.Load <TAsset>(AssetTestContainer.ToStream(baseYaml), $"MyAsset{Types.FileExtension}");
            var derivedAsset     = AssetFileSerializer.Load <TAsset>(AssetTestContainer.ToStream(derivedYaml), $"MyDerivedAsset{Types.FileExtension}");
            var baseContainer    = new AssetTestContainer <TAsset, TAssetPropertyGraph>(container, baseAsset.Asset);
            var derivedContainer = new AssetTestContainer <TAsset, TAssetPropertyGraph>(container, derivedAsset.Asset);

            baseAsset.YamlMetadata.CopyInto(baseContainer.AssetItem.YamlMetadata);
            derivedAsset.YamlMetadata.CopyInto(derivedContainer.AssetItem.YamlMetadata);
            baseContainer.BuildGraph();
            derivedContainer.BuildGraph();
            var result = new DeriveAssetTest <TAsset, TAssetPropertyGraph>(baseContainer, derivedContainer, null);

            derivedContainer.Graph.RefreshBase();
            return(result);
        }