// Tests http://tracker.ship.scea.com/jira/browse/WWSATF-1370 // Test adding two types of extensions that have the same Name but different FullName. public void TestDuplicateNames() { var domType = new DomNodeType("domType"); var extension = new ExtensionInfo <TestExtensionInfo>(); domType.Define(extension); var domDerivedType = new DomNodeType("domDerivedType", domType); var anotherExtension = new ExtensionInfo <AnotherName.TestExtensionInfo>(); domDerivedType.Define(anotherExtension); var domNode = new DomNode(domDerivedType); domNode.InitializeExtensions(); Assert.IsTrue(domNode.GetExtension(extension).GetType() == typeof(TestExtensionInfo)); Assert.IsTrue(domNode.GetExtension(anotherExtension).GetType() == typeof(AnotherName.TestExtensionInfo)); ExtensionInfo getInfo = domType.GetExtensionInfo("UnitTests.Atf.Dom.TestExtensionInfo"); Assert.IsNotNull(getInfo); Assert.AreEqual(getInfo, extension); getInfo = domDerivedType.GetExtensionInfo("UnitTests.Atf.Dom.TestExtensionInfo"); Assert.IsNotNull(getInfo); Assert.AreEqual(getInfo, extension); ExtensionInfo anotherGetInfo = domDerivedType.GetExtensionInfo("UnitTests.Atf.Dom.AnotherName.TestExtensionInfo"); Assert.IsNotNull(anotherGetInfo); Assert.AreEqual(anotherGetInfo, anotherExtension); }
// Tests http://tracker.ship.scea.com/jira/browse/WWSATF-1370 // Test adding two types of extensions that have the same Name but different FullName. public void TestDuplicateNames() { var domType = new DomNodeType("domType"); var extension = new ExtensionInfo<TestExtensionInfo>(); domType.Define(extension); var domDerivedType = new DomNodeType("domDerivedType", domType); var anotherExtension = new ExtensionInfo<AnotherName.TestExtensionInfo>(); domDerivedType.Define(anotherExtension); var domNode = new DomNode(domDerivedType); domNode.InitializeExtensions(); Assert.IsTrue(domNode.GetExtension(extension).GetType() == typeof(TestExtensionInfo)); Assert.IsTrue(domNode.GetExtension(anotherExtension).GetType() == typeof(AnotherName.TestExtensionInfo)); ExtensionInfo getInfo = domType.GetExtensionInfo("UnitTests.Atf.Dom.TestExtensionInfo"); Assert.IsNotNull(getInfo); Assert.AreEqual(getInfo, extension); getInfo = domDerivedType.GetExtensionInfo("UnitTests.Atf.Dom.TestExtensionInfo"); Assert.IsNotNull(getInfo); Assert.AreEqual(getInfo, extension); ExtensionInfo anotherGetInfo = domDerivedType.GetExtensionInfo("UnitTests.Atf.Dom.AnotherName.TestExtensionInfo"); Assert.IsNotNull(anotherGetInfo); Assert.AreEqual(anotherGetInfo, anotherExtension); }
public void TestOverriddenExtensionInfo() { ExtensionInfo info = new ExtensionInfo <TestDomNodeType>("foo"); DomNodeType test = new DomNodeType( "test", null, EmptyEnumerable <AttributeInfo> .Instance, EmptyEnumerable <ChildInfo> .Instance, new ExtensionInfo[] { info }); ExtensionInfo overridden = new ExtensionInfo <TestDomNodeType>("foo"); DomNodeType child = new DomNodeType("child", test, EmptyEnumerable <AttributeInfo> .Instance, EmptyEnumerable <ChildInfo> .Instance, new ExtensionInfo[] { overridden }); Assert.AreSame(child.GetExtensionInfo("foo"), overridden); Assert.AreEqual(overridden.OwningType, child); Assert.AreEqual(overridden.DefiningType, test); Assert.True(info.Equivalent(overridden)); Assert.True(overridden.Equivalent(info)); Assert.True(test.IsValid(overridden)); Assert.True(child.IsValid(info)); }
public void TestCustomExtensionInfo() { ExtensionInfo info = new ExtensionInfo <TestDomNodeType>("foo"); DomNodeType test = new DomNodeType( "test", null, EmptyEnumerable <AttributeInfo> .Instance, EmptyEnumerable <ChildInfo> .Instance, new ExtensionInfo[] { info }); Utilities.TestSequenceEqual(test.Extensions, info); Assert.True(test.IsValid(info)); Assert.AreSame(test.GetExtensionInfo("foo"), info); // check that type is now frozen Assert.Throws <InvalidOperationException>(delegate { test.Define(new ExtensionInfo <TestDomNodeType>("foo")); }); Assert.AreEqual(info.OwningType, test); Assert.AreEqual(info.DefiningType, test); Assert.Null(test.GetExtensionInfo("bar")); }
public void TestInheritedExtensionInfo() { ExtensionInfo info = new ExtensionInfo <TestDomNodeType>("foo"); DomNodeType test = new DomNodeType( "test", null, EmptyEnumerable <AttributeInfo> .Instance, EmptyEnumerable <ChildInfo> .Instance, new ExtensionInfo[] { info }); DomNodeType child = new DomNodeType("child"); child.BaseType = test; ExtensionInfo inherited = child.GetExtensionInfo("foo"); Assert.AreEqual(inherited.OwningType, test); Assert.AreEqual(inherited.DefiningType, test); Assert.True(inherited.Equivalent(info)); Assert.True(info.Equivalent(inherited)); }
public void TestDuplicateExtensionInfo() { var ext1 = new ExtensionInfo <TestAdapter1>("foo"); var ext2 = new ExtensionInfo <TestAdapter2>("foo"); var domType = new DomNodeType( "test", null, EmptyEnumerable <AttributeInfo> .Instance, EmptyEnumerable <ChildInfo> .Instance, new ExtensionInfo[] { ext1, ext2 }); var domNode = new DomNode(domType); object resultExt1 = domNode.GetExtension(ext1); object resultExt2 = domNode.GetExtension(ext2); Assert.IsTrue(resultExt1 is TestAdapter1); Assert.IsTrue(resultExt2 is TestAdapter2); object[] decorators = domNode.GetDecorators(typeof(object)).ToArray(); Assert.IsTrue( decorators.Length == 2 && decorators[0] == resultExt1 && decorators[1] == resultExt2); DomNodeAdapter[] extensions = domNode.AsAll <DomNodeAdapter>().ToArray(); Assert.IsTrue( extensions.Length == 2 && extensions[0] == resultExt1 && extensions[1] == resultExt2); // Searching by name is a problem, though. The search is ambiguous. // See tracker item for discussion: http://tracker.ship.scea.com/jira/browse/WWSATF-522 Assert.Throws <InvalidOperationException>(() => domType.GetExtensionInfo("foo")); }
public void TestDuplicateExtensionInfo() { var ext1 = new ExtensionInfo<TestAdapter1>("foo"); var ext2 = new ExtensionInfo<TestAdapter2>("foo"); var domType = new DomNodeType( "test", null, EmptyEnumerable<AttributeInfo>.Instance, EmptyEnumerable<ChildInfo>.Instance, new ExtensionInfo[] { ext1, ext2 }); var domNode = new DomNode(domType); object resultExt1 = domNode.GetExtension(ext1); object resultExt2 = domNode.GetExtension(ext2); Assert.IsTrue(resultExt1 is TestAdapter1); Assert.IsTrue(resultExt2 is TestAdapter2); object[] decorators = domNode.GetDecorators(typeof(object)).ToArray(); Assert.IsTrue( decorators.Length == 2 && decorators[0] == resultExt1 && decorators[1] == resultExt2); DomNodeAdapter[] extensions = domNode.AsAll<DomNodeAdapter>().ToArray(); Assert.IsTrue( extensions.Length == 2 && extensions[0] == resultExt1 && extensions[1] == resultExt2); // Searching by name is a problem, though. The search is ambiguous. // See tracker item for discussion: http://tracker.ship.scea.com/jira/browse/WWSATF-522 Assert.Throws<InvalidOperationException>(() => domType.GetExtensionInfo("foo")); }
public void TestOverriddenExtensionInfo() { ExtensionInfo info = new ExtensionInfo<TestDomNodeType>("foo"); DomNodeType test = new DomNodeType( "test", null, EmptyEnumerable<AttributeInfo>.Instance, EmptyEnumerable<ChildInfo>.Instance, new ExtensionInfo[] { info }); ExtensionInfo overridden = new ExtensionInfo<TestDomNodeType>("foo"); DomNodeType child = new DomNodeType("child", test, EmptyEnumerable<AttributeInfo>.Instance, EmptyEnumerable<ChildInfo>.Instance, new ExtensionInfo[] { overridden }); Assert.AreSame(child.GetExtensionInfo("foo"), overridden); Assert.AreEqual(overridden.OwningType, child); Assert.AreEqual(overridden.DefiningType, test); Assert.True(info.Equivalent(overridden)); Assert.True(overridden.Equivalent(info)); Assert.True(test.IsValid(overridden)); Assert.True(child.IsValid(info)); }
public void TestInheritedExtensionInfo() { ExtensionInfo info = new ExtensionInfo<TestDomNodeType>("foo"); DomNodeType test = new DomNodeType( "test", null, EmptyEnumerable<AttributeInfo>.Instance, EmptyEnumerable<ChildInfo>.Instance, new ExtensionInfo[] { info }); DomNodeType child = new DomNodeType("child"); child.BaseType = test; ExtensionInfo inherited = child.GetExtensionInfo("foo"); Assert.AreEqual(inherited.OwningType, test); Assert.AreEqual(inherited.DefiningType, test); Assert.True(inherited.Equivalent(info)); Assert.True(info.Equivalent(inherited)); }
public void TestCustomExtensionInfo() { ExtensionInfo info = new ExtensionInfo<TestDomNodeType>("foo"); DomNodeType test = new DomNodeType( "test", null, EmptyEnumerable<AttributeInfo>.Instance, EmptyEnumerable<ChildInfo>.Instance, new ExtensionInfo[] { info }); Utilities.TestSequenceEqual(test.Extensions, info); Assert.True(test.IsValid(info)); Assert.AreSame(test.GetExtensionInfo("foo"), info); // check that type is now frozen Assert.Throws<InvalidOperationException>(delegate { test.Define(new ExtensionInfo<TestDomNodeType>("foo")); }); Assert.AreEqual(info.OwningType, test); Assert.AreEqual(info.DefiningType, test); Assert.Null(test.GetExtensionInfo("bar")); }