Skip to content
This repository has been archived by the owner on Aug 22, 2018. It is now read-only.

Commit

Permalink
Merge pull request #45 in XK/xenko from benlitz/quantum5 to master-1.9
Browse files Browse the repository at this point in the history
* commit '706fe8253f0f9bb4bd91ffa277abd589a66b73bc': (28 commits)
  [Quantum] Introduce CollectionUpdate as ContentChangeType
  [Quantum] Remove any PrepareChange/FinalizeChange from public API
  [Quantum] Remove PrepareChange and FinalizeChange from public interface IMemberNode
  [Quantum] Remove contentUpdating variable, using UpdatingPropertyFromBase instead
  [Quantum] Don't use PrepareChange and FinalizeChange directly on member node, we would like to remove these events. Seems to work with normal Changing/Changed events
  [Quantum] Remove obsolete GraphNodeChangeListener
  [Quantum] Split Reference into TargetReference and ItemReferences
  [Quantum] Fix refresh of references to boxed contents when the actual value changes type (when container is "object" for instance)
  [Quantum] Remove an assert that doesn't make sense anymore
  [Quantum] Fix creation of BoxedContent for non-struct boxed primitive types
  [Quantum] Remove the Content member of IContentNode
  [Quantum] Clean up content node and derived classes
  [Quantum] TargetNode is now a member of IMemberNode instead of IContentNode
  [Quantum] Remove several members of IReference
  [Quantum] Remove index from ReferenceEnumerable
  [Quantum] Add more tests
  [Quantum] Move TryGetChild into IObjectNode
  [Quantum] Move node events into IMemberNode
  [Quantum] Move the indexer accessor into IObjectNode
  [Quantum] Move the Children collection into IObjectNode and rename it Members
  ...
  • Loading branch information
Benjamin Litzelmann committed Jan 25, 2017
2 parents e590553 + 0c7ed9b commit 4909397
Show file tree
Hide file tree
Showing 60 changed files with 1,714 additions and 1,532 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using NUnit.Framework;
using SiliconStudio.Core.Reflection;
using SiliconStudio.Quantum;
using SiliconStudio.Quantum.Contents;

namespace SiliconStudio.Assets.Quantum.Tests
{
Expand All @@ -16,8 +15,8 @@ public void TestSimpleDictionaryAddWithCollision()
var context = DeriveAssetTest<Types.MyAsset3>.DeriveAsset(asset);
var baseIds = CollectionItemIdHelper.GetCollectionItemIds(context.BaseAsset.MyDictionary);
var derivedIds = CollectionItemIdHelper.GetCollectionItemIds(context.DerivedAsset.MyDictionary);
var basePropertyNode = (AssetMemberNode)((IContentNode)context.BaseGraph.RootNode).TryGetChild(nameof(Types.MyAsset3.MyDictionary));
var derivedPropertyNode = (AssetMemberNode)((IContentNode)context.DerivedGraph.RootNode).TryGetChild(nameof(Types.MyAsset3.MyDictionary));
var basePropertyNode = (AssetMemberNode)context.BaseGraph.RootNode[nameof(Types.MyAsset3.MyDictionary)];
var derivedPropertyNode = (AssetMemberNode)context.DerivedGraph.RootNode[nameof(Types.MyAsset3.MyDictionary)];

// Update a key to derived and then the same key to the base
derivedPropertyNode.Add("String3", new Index("Key3"));
Expand Down Expand Up @@ -59,8 +58,8 @@ public void TestSimpleCollectionRemoveDeleted()
var context = DeriveAssetTest<Types.MyAsset2>.DeriveAsset(asset);
var baseIds = CollectionItemIdHelper.GetCollectionItemIds(context.BaseAsset.MyStrings);
var derivedIds = CollectionItemIdHelper.GetCollectionItemIds(context.DerivedAsset.MyStrings);
var basePropertyNode = (AssetMemberNode)((IContentNode)context.BaseGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));
var derivedPropertyNode = (AssetMemberNode)((IContentNode)context.DerivedGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));
var basePropertyNode = (AssetMemberNode)context.BaseGraph.RootNode[nameof(Types.MyAsset2.MyStrings)];
var derivedPropertyNode = (AssetMemberNode)context.DerivedGraph.RootNode[nameof(Types.MyAsset2.MyStrings)];

// Delete an item from the derived and then delete the same from the base
var derivedDeletedId = derivedIds[2];
Expand Down Expand Up @@ -101,8 +100,8 @@ public void TestSimpleDictionaryRemoveDeleted()
var context = DeriveAssetTest<Types.MyAsset3>.DeriveAsset(asset);
var baseIds = CollectionItemIdHelper.GetCollectionItemIds(context.BaseAsset.MyDictionary);
var derivedIds = CollectionItemIdHelper.GetCollectionItemIds(context.DerivedAsset.MyDictionary);
var basePropertyNode = (AssetMemberNode)((IContentNode)context.BaseGraph.RootNode).TryGetChild(nameof(Types.MyAsset3.MyDictionary));
var derivedPropertyNode = (AssetMemberNode)((IContentNode)context.DerivedGraph.RootNode).TryGetChild(nameof(Types.MyAsset3.MyDictionary));
var basePropertyNode = (AssetMemberNode)context.BaseGraph.RootNode[nameof(Types.MyAsset3.MyDictionary)];
var derivedPropertyNode = (AssetMemberNode)context.DerivedGraph.RootNode[nameof(Types.MyAsset3.MyDictionary)];

// Delete an item from the derived and then delete the same from the base
var derivedDeletedId = derivedIds["Key3"];
Expand Down Expand Up @@ -143,8 +142,8 @@ public void TestSimpleCollectionUpdateDeleted()
var context = DeriveAssetTest<Types.MyAsset2>.DeriveAsset(asset);
var baseIds = CollectionItemIdHelper.GetCollectionItemIds(context.BaseAsset.MyStrings);
var derivedIds = CollectionItemIdHelper.GetCollectionItemIds(context.DerivedAsset.MyStrings);
var basePropertyNode = (AssetMemberNode)((IContentNode)context.BaseGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));
var derivedPropertyNode = (AssetMemberNode)((IContentNode)context.DerivedGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));
var basePropertyNode = (AssetMemberNode)context.BaseGraph.RootNode[nameof(Types.MyAsset2.MyStrings)];
var derivedPropertyNode = (AssetMemberNode)context.DerivedGraph.RootNode[nameof(Types.MyAsset2.MyStrings)];

// Delete an item from the derived and then update the same from the base
var derivedDeletedId = derivedIds[2];
Expand Down Expand Up @@ -185,8 +184,8 @@ public void TestSimpleDictionaryUpdateDeleted()
var context = DeriveAssetTest<Types.MyAsset3>.DeriveAsset(asset);
var baseIds = CollectionItemIdHelper.GetCollectionItemIds(context.BaseAsset.MyDictionary);
var derivedIds = CollectionItemIdHelper.GetCollectionItemIds(context.DerivedAsset.MyDictionary);
var basePropertyNode = (AssetMemberNode)((IContentNode)context.BaseGraph.RootNode).TryGetChild(nameof(Types.MyAsset3.MyDictionary));
var derivedPropertyNode = (AssetMemberNode)((IContentNode)context.DerivedGraph.RootNode).TryGetChild(nameof(Types.MyAsset3.MyDictionary));
var basePropertyNode = (AssetMemberNode)context.BaseGraph.RootNode[nameof(Types.MyAsset3.MyDictionary)];
var derivedPropertyNode = (AssetMemberNode)context.DerivedGraph.RootNode[nameof(Types.MyAsset3.MyDictionary)];

// Delete an item from the derived and then update the same from the base
var derivedDeletedId = derivedIds["Key3"];
Expand Down Expand Up @@ -227,39 +226,39 @@ public void TestSimpleCollectionAddMultipleAndCheckOrder()
var context = DeriveAssetTest<Types.MyAsset2>.DeriveAsset(asset);
var baseIds = CollectionItemIdHelper.GetCollectionItemIds(context.BaseAsset.MyStrings);
var derivedIds = CollectionItemIdHelper.GetCollectionItemIds(context.DerivedAsset.MyStrings);
var basePropertyNode = (IAssetNode)((IContentNode)context.BaseGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));
var derivedPropertyNode = (IAssetNode)((IContentNode)context.DerivedGraph.RootNode).TryGetChild(nameof(Types.MyAsset2.MyStrings));
var basePropertyNode = (IAssetNode)context.BaseGraph.RootNode[nameof(Types.MyAsset2.MyStrings)];
var derivedPropertyNode = (IAssetNode)context.DerivedGraph.RootNode[nameof(Types.MyAsset2.MyStrings)];

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

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

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

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

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

((ContentNode)basePropertyNode).Add("String4.1", new Index(8));
basePropertyNode.Add("String4.1", new Index(8));
Assert.AreEqual(9, context.BaseAsset.MyStrings.Count);
AssertCollection(basePropertyNode, "String0.1", "String1", "String1.1", "String2", "String2.1", "String3", "String3.1", "String4", "String4.1");
Assert.AreEqual(11, context.DerivedAsset.MyStrings.Count);
Expand Down
Loading

0 comments on commit 4909397

Please sign in to comment.