public void TestCollectionItemIdentifierWithDuplicates() { var container = new AssetPropertyGraphContainer(new AssetNodeContainer { NodeBuilder = { NodeFactory = 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.Equal(IdentifierGenerator.Get(100), ids[0]); Assert.Equal(IdentifierGenerator.Get(200), ids[1]); Assert.Equal(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.Equal(3, ids.KeyCount); Assert.Equal(0, ids.DeletedCount); Assert.Equal(IdentifierGenerator.Get(100), ids[0]); Assert.Equal(IdentifierGenerator.Get(200), ids[1]); Assert.NotEqual(IdentifierGenerator.Get(100), ids[2]); Assert.NotEqual(IdentifierGenerator.Get(200), ids[2]); }
protected CopyPasteTest([NotNull] Asset asset) { Container = new AssetPropertyGraphContainer(new AssetNodeContainer { NodeBuilder = { NodeFactory = new AssetNodeFactory() } }); AssetItem = new AssetItem("MyAsset", asset); var assetGraph = AssetQuantumRegistry.ConstructPropertyGraph(Container, AssetItem, null); Assert.IsAssignableFrom <EntityHierarchyPropertyGraph>(assetGraph); AssetGraph = (EntityHierarchyPropertyGraph)assetGraph; }
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 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); }
protected void BuildGraph() { var baseGraph = AssetQuantumRegistry.ConstructPropertyGraph(Container, BaseAssetItem, null); Assert.IsAssignableFrom <MyAssetBasePropertyGraph>(baseGraph); BaseGraph = (MyAssetBasePropertyGraph)baseGraph; var derivedGraph = AssetQuantumRegistry.ConstructPropertyGraph(Container, DerivedAssetItem, null); Assert.IsAssignableFrom <MyAssetBasePropertyGraph>(baseGraph); DerivedGraph = (MyAssetBasePropertyGraph)derivedGraph; DerivedGraph.RefreshBase(BaseGraph); }
public void TestSimpleConstruction() { var container = new AssetPropertyGraphContainer(new AssetNodeContainer { NodeBuilder = { NodeFactory = new AssetNodeFactory() } }); var asset = new Types.MyAsset1 { MyString = "String" }; var assetItem = new AssetItem("MyAsset", asset); var graph = AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null); Assert.IsAssignableFrom <AssetObjectNode>(graph.RootNode); }
public void TestSimpleCollectionUpdate() { var container = new AssetPropertyGraphContainer(new AssetNodeContainer { NodeBuilder = { NodeFactory = new AssetNodeFactory() } }); var asset = new Types.MyAsset2 { MyStrings = { "aaa", "bbb", "ccc" } }; var assetItem = new AssetItem("MyAsset", asset); var graph = AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null); var node = graph.RootNode[nameof(Types.MyAsset2.MyStrings)]; //var ids = CollectionItemIdHelper.TryGetCollectionItemIds(asset.MyStrings, out itemIds); }
public static Types.MyAssetHierarchyPropertyGraph BuildAssetAndGraph(int rootCount, int depth, int childPerPart, Action <AssetCompositeHierarchyData <Types.MyPartDesign, Types.MyPart> > initializeProperties = null) { var container = new AssetPropertyGraphContainer(new AssetNodeContainer { NodeBuilder = { NodeFactory = new AssetNodeFactory() } }); var asset = BuildHierarchy(rootCount, depth, childPerPart); var assetItem = new AssetItem("MyAsset", asset); initializeProperties?.Invoke(asset.Hierarchy); var graph = (Types.MyAssetHierarchyPropertyGraph)AssetQuantumRegistry.ConstructPropertyGraph(container, assetItem, null); return(graph); }
private AssetPropertyGraph CreateScene(params Entity[] entities) { var scene = new SceneAsset(); foreach (var entity in entities) { scene.Hierarchy.RootParts.Add(entity); scene.Hierarchy.Parts.Add(new EntityDesign(entity)); } var assetItem = new AssetItem("", scene); var propertyGraph = AssetQuantumRegistry.ConstructPropertyGraph(propertyGraphContainer, assetItem, null); propertyGraphContainer.RegisterGraph(propertyGraph); return(propertyGraph); }
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)); }