Пример #1
0
        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));
        }
Пример #2
0
        public void TestCustomAttributeInfo()
        {
            AttributeInfo info = new AttributeInfo("foo", new AttributeType("foo", typeof(string)));
            DomNodeType   test = new DomNodeType(
                "test",
                null,
                new AttributeInfo[] { info },
                EmptyEnumerable <ChildInfo> .Instance,
                EmptyEnumerable <ExtensionInfo> .Instance);

            Utilities.TestSequenceEqual(test.Attributes, info);
            Assert.True(test.IsValid(info));
            Assert.AreSame(test.GetAttributeInfo("foo"), info);
            // check that type is now frozen
            Assert.Throws <InvalidOperationException>(delegate { test.Define(GetStringAttribute("notFoo")); });

            Assert.AreEqual(info.OwningType, test);
            Assert.AreEqual(info.DefiningType, test);
            Assert.Null(test.GetAttributeInfo("bar"));
        }
Пример #3
0
        public void TestCustomAttributeInfo()
        {
            AttributeInfo info = new AttributeInfo("foo", new AttributeType("foo", typeof(string)));
            DomNodeType test = new DomNodeType(
                "test",
                null,
                new AttributeInfo[] { info },
                EmptyEnumerable<ChildInfo>.Instance,
                EmptyEnumerable<ExtensionInfo>.Instance);

            Utilities.TestSequenceEqual(test.Attributes, info);
            Assert.True(test.IsValid(info));
            Assert.AreSame(test.GetAttributeInfo("foo"), info);
            // check that type is now frozen
            Assert.Throws<InvalidOperationException>(delegate { test.Define(GetStringAttribute("notFoo")); });

            Assert.AreEqual(info.OwningType, test);
            Assert.AreEqual(info.DefiningType, test);
            Assert.Null(test.GetAttributeInfo("bar"));
        }
Пример #4
0
        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));
        }