public void TestPrimitiveMember() { const string primitiveMemberBaseYaml = @"!SiliconStudio.Assets.Quantum.Tests.Types+MyAsset1,SiliconStudio.Assets.Quantum.Tests Id: 10000000-0000-0000-0000-000000000000 Tags: [] MyString: MyBaseString "; const string primitiveMemberOverridenYaml = @"!SiliconStudio.Assets.Quantum.Tests.Types+MyAsset1,SiliconStudio.Assets.Quantum.Tests Id: 30000000-0000-0000-0000-000000000000 Archetype: 10000000-0000-0000-0000-000000000000:MyAsset Tags: [] MyString*: MyDerivedString "; const string primitiveMemberToReconcileYaml = @"!SiliconStudio.Assets.Quantum.Tests.Types+MyAsset1,SiliconStudio.Assets.Quantum.Tests Id: 20000000-0000-0000-0000-000000000000 Archetype: 10000000-0000-0000-0000-000000000000:MyAsset Tags: [] MyString: MyDerivedString "; var context = DeriveAssetTest <Types.MyAsset1> .LoadFromYaml(primitiveMemberBaseYaml, primitiveMemberOverridenYaml); Assert.AreEqual("MyBaseString", context.BaseAsset.MyString); Assert.AreEqual("MyDerivedString", context.DerivedAsset.MyString); context.DerivedGraph.ReconcileWithBase(); Assert.AreEqual("MyBaseString", context.BaseAsset.MyString); Assert.AreEqual("MyDerivedString", context.DerivedAsset.MyString); context = DeriveAssetTest <Types.MyAsset1> .LoadFromYaml(primitiveMemberBaseYaml, primitiveMemberToReconcileYaml); Assert.AreEqual("MyBaseString", context.BaseAsset.MyString); Assert.AreEqual("MyDerivedString", context.DerivedAsset.MyString); context.DerivedGraph.ReconcileWithBase(); Assert.AreEqual("MyBaseString", context.BaseAsset.MyString); Assert.AreEqual("MyBaseString", context.DerivedAsset.MyString); }
public void TestDictionaryAddedKeyInBase() { const string baseYaml = @"!SiliconStudio.Assets.Quantum.Tests.Types+MyAsset3,SiliconStudio.Assets.Quantum.Tests Id: 10000000-0000-0000-0000-000000000000 Tags: [] MyDictionary: 0a0000000a0000000a0000000a000000~Key1: String1 15000000150000001500000015000000~Key2.5: String2.5 14000000140000001400000014000000~Key2: String2 "; const string derivedYaml = @"!SiliconStudio.Assets.Quantum.Tests.Types+MyAsset3,SiliconStudio.Assets.Quantum.Tests Id: 20000000-0000-0000-0000-000000000000 Archetype: 10000000-0000-0000-0000-000000000000:MyAsset Tags: [] MyDictionary: 0a0000000a0000000a0000000a000000~Key1: String1 14000000140000001400000014000000~Key2: String2 "; var context = DeriveAssetTest <Types.MyAsset3> .LoadFromYaml(baseYaml, derivedYaml); var baseIds = CollectionItemIdHelper.GetCollectionItemIds(context.BaseAsset.MyDictionary); var derivedIds = CollectionItemIdHelper.GetCollectionItemIds(context.DerivedAsset.MyDictionary); Assert.AreEqual(3, context.BaseAsset.MyDictionary.Count); Assert.AreEqual("String1", context.BaseAsset.MyDictionary["Key1"]); Assert.AreEqual("String2.5", context.BaseAsset.MyDictionary["Key2.5"]); Assert.AreEqual("String2", context.BaseAsset.MyDictionary["Key2"]); Assert.AreEqual(2, context.DerivedAsset.MyDictionary.Count); Assert.AreEqual("String1", context.DerivedAsset.MyDictionary["Key1"]); Assert.AreEqual("String2", context.DerivedAsset.MyDictionary["Key2"]); Assert.AreEqual(3, baseIds.KeyCount); Assert.AreEqual(0, baseIds.DeletedCount); Assert.AreEqual(IdentifierGenerator.Get(10), baseIds["Key1"]); Assert.AreEqual(IdentifierGenerator.Get(21), baseIds["Key2.5"]); Assert.AreEqual(IdentifierGenerator.Get(20), baseIds["Key2"]); Assert.AreEqual(2, derivedIds.KeyCount); Assert.AreEqual(0, derivedIds.DeletedCount); Assert.AreEqual(IdentifierGenerator.Get(10), derivedIds["Key1"]); Assert.AreEqual(IdentifierGenerator.Get(20), derivedIds["Key2"]); context.DerivedGraph.ReconcileWithBase(); Assert.AreEqual(3, context.BaseAsset.MyDictionary.Count); Assert.AreEqual("String1", context.BaseAsset.MyDictionary["Key1"]); Assert.AreEqual("String2.5", context.BaseAsset.MyDictionary["Key2.5"]); Assert.AreEqual("String2", context.BaseAsset.MyDictionary["Key2"]); Assert.AreEqual(3, context.DerivedAsset.MyDictionary.Count); Assert.AreEqual("String1", context.DerivedAsset.MyDictionary["Key1"]); Assert.AreEqual("String2.5", context.DerivedAsset.MyDictionary["Key2.5"]); Assert.AreEqual("String2", context.DerivedAsset.MyDictionary["Key2"]); Assert.AreEqual(3, baseIds.KeyCount); Assert.AreEqual(0, baseIds.DeletedCount); Assert.AreEqual(IdentifierGenerator.Get(10), baseIds["Key1"]); Assert.AreEqual(IdentifierGenerator.Get(21), baseIds["Key2.5"]); Assert.AreEqual(IdentifierGenerator.Get(20), baseIds["Key2"]); Assert.AreEqual(3, derivedIds.KeyCount); Assert.AreEqual(0, derivedIds.DeletedCount); Assert.AreEqual(IdentifierGenerator.Get(10), derivedIds["Key1"]); Assert.AreEqual(IdentifierGenerator.Get(21), derivedIds["Key2.5"]); Assert.AreEqual(IdentifierGenerator.Get(20), derivedIds["Key2"]); }
public void TestCollectionRemovedItemFromBase() { const string baseYaml = @"!SiliconStudio.Assets.Quantum.Tests.Types+MyAsset2,SiliconStudio.Assets.Quantum.Tests Id: 10000000-0000-0000-0000-000000000000 Tags: [] Struct: MyStrings: {} MyStrings: 0a0000000a0000000a0000000a000000: String1 14000000140000001400000014000000: String3 "; const string derivedYaml = @"!SiliconStudio.Assets.Quantum.Tests.Types+MyAsset2,SiliconStudio.Assets.Quantum.Tests Id: 20000000-0000-0000-0000-000000000000 Archetype: 10000000-0000-0000-0000-000000000000:MyAsset Tags: [] Struct: MyStrings: {} MyStrings: 0a0000000a0000000a0000000a000000: String1 24000000240000002400000024000000: String2 14000000140000001400000014000000: String3 "; var context = DeriveAssetTest <Types.MyAsset2> .LoadFromYaml(baseYaml, derivedYaml); var baseIds = CollectionItemIdHelper.GetCollectionItemIds(context.BaseAsset.MyStrings); var derivedIds = CollectionItemIdHelper.GetCollectionItemIds(context.DerivedAsset.MyStrings); Assert.AreEqual(2, context.BaseAsset.MyStrings.Count); Assert.AreEqual("String1", context.BaseAsset.MyStrings[0]); Assert.AreEqual("String3", context.BaseAsset.MyStrings[1]); Assert.AreEqual(3, context.DerivedAsset.MyStrings.Count); Assert.AreEqual("String1", context.DerivedAsset.MyStrings[0]); Assert.AreEqual("String2", context.DerivedAsset.MyStrings[1]); Assert.AreEqual("String3", context.DerivedAsset.MyStrings[2]); Assert.AreEqual(2, baseIds.KeyCount); Assert.AreEqual(0, baseIds.DeletedCount); Assert.AreEqual(IdentifierGenerator.Get(10), baseIds[0]); Assert.AreEqual(IdentifierGenerator.Get(20), baseIds[1]); Assert.AreEqual(3, derivedIds.KeyCount); Assert.AreEqual(0, derivedIds.DeletedCount); Assert.AreEqual(IdentifierGenerator.Get(10), derivedIds[0]); Assert.AreEqual(IdentifierGenerator.Get(36), derivedIds[1]); Assert.AreEqual(IdentifierGenerator.Get(20), derivedIds[2]); context.DerivedGraph.ReconcileWithBase(); Assert.AreEqual(2, context.BaseAsset.MyStrings.Count); Assert.AreEqual("String1", context.BaseAsset.MyStrings[0]); Assert.AreEqual("String3", context.BaseAsset.MyStrings[1]); Assert.AreEqual(2, context.DerivedAsset.MyStrings.Count); Assert.AreEqual("String1", context.DerivedAsset.MyStrings[0]); Assert.AreEqual("String3", context.DerivedAsset.MyStrings[1]); Assert.AreEqual(2, baseIds.KeyCount); Assert.AreEqual(0, baseIds.DeletedCount); Assert.AreEqual(IdentifierGenerator.Get(10), baseIds[0]); Assert.AreEqual(IdentifierGenerator.Get(20), baseIds[1]); Assert.AreEqual(2, derivedIds.KeyCount); Assert.AreEqual(0, derivedIds.DeletedCount); Assert.AreEqual(IdentifierGenerator.Get(10), derivedIds[0]); Assert.AreEqual(IdentifierGenerator.Get(20), derivedIds[1]); }
public void TestDictionaryRemovedDeletedItemFromBase() { const string baseYaml = @"!SiliconStudio.Assets.Quantum.Tests.Types+MyAsset3,SiliconStudio.Assets.Quantum.Tests Id: 10000000-0000-0000-0000-000000000000 Tags: [] MyDictionary: 0a0000000a0000000a0000000a000000~Key1: String1 24000000240000002400000024000000~Key3: String3 "; const string derivedYaml = @"!SiliconStudio.Assets.Quantum.Tests.Types+MyAsset3,SiliconStudio.Assets.Quantum.Tests Id: 20000000-0000-0000-0000-000000000000 Archetype: 10000000-0000-0000-0000-000000000000:MyAsset Tags: [] MyDictionary: 0a0000000a0000000a0000000a000000~Key1: String1 24000000240000002400000024000000~Key3: String2 14000000140000001400000014000000~: ~(Deleted) "; var context = DeriveAssetTest <Types.MyAsset3> .LoadFromYaml(baseYaml, derivedYaml); var baseIds = CollectionItemIdHelper.GetCollectionItemIds(context.BaseAsset.MyDictionary); var derivedIds = CollectionItemIdHelper.GetCollectionItemIds(context.DerivedAsset.MyDictionary); Assert.AreEqual(2, context.BaseAsset.MyDictionary.Count); Assert.AreEqual("String1", context.BaseAsset.MyDictionary["Key1"]); Assert.AreEqual("String3", context.BaseAsset.MyDictionary["Key3"]); Assert.AreEqual(2, context.DerivedAsset.MyDictionary.Count); Assert.AreEqual("String1", context.DerivedAsset.MyDictionary["Key1"]); Assert.AreEqual("String2", context.DerivedAsset.MyDictionary["Key3"]); Assert.AreEqual(2, baseIds.KeyCount); Assert.AreEqual(0, baseIds.DeletedCount); Assert.AreEqual(IdentifierGenerator.Get(10), baseIds["Key1"]); Assert.AreEqual(IdentifierGenerator.Get(36), baseIds["Key3"]); Assert.AreEqual(2, derivedIds.KeyCount); Assert.AreEqual(1, derivedIds.DeletedCount); Assert.AreEqual(IdentifierGenerator.Get(10), derivedIds["Key1"]); Assert.AreEqual(IdentifierGenerator.Get(36), derivedIds["Key3"]); Assert.AreEqual(IdentifierGenerator.Get(20), derivedIds.DeletedItems.Single()); context.DerivedGraph.ReconcileWithBase(); Assert.AreEqual(2, context.BaseAsset.MyDictionary.Count); Assert.AreEqual("String1", context.BaseAsset.MyDictionary["Key1"]); Assert.AreEqual("String3", context.BaseAsset.MyDictionary["Key3"]); Assert.AreEqual(2, context.DerivedAsset.MyDictionary.Count); Assert.AreEqual("String1", context.DerivedAsset.MyDictionary["Key1"]); Assert.AreEqual("String3", context.DerivedAsset.MyDictionary["Key3"]); Assert.AreEqual(2, baseIds.KeyCount); Assert.AreEqual(0, baseIds.DeletedCount); Assert.AreEqual(IdentifierGenerator.Get(10), baseIds["Key1"]); Assert.AreEqual(IdentifierGenerator.Get(36), baseIds["Key3"]); Assert.AreEqual(2, derivedIds.KeyCount); Assert.AreEqual(0, derivedIds.DeletedCount); Assert.AreEqual(IdentifierGenerator.Get(10), derivedIds["Key1"]); Assert.AreEqual(IdentifierGenerator.Get(36), derivedIds["Key3"]); }