Пример #1
0
        public void AmbiguousPropertyTest()
        {
            EdmComplexType complex = new EdmComplexType("Bar", "Foo");

            StubEdmStructuralProperty prop1 = new StubEdmStructuralProperty("Foo");
            StubEdmStructuralProperty prop2 = new StubEdmStructuralProperty("Foo");
            StubEdmStructuralProperty prop3 = new StubEdmStructuralProperty("Foo");

            prop1.DeclaringType = complex;
            prop2.DeclaringType = complex;
            prop3.DeclaringType = complex;

            complex.AddProperty(prop1);
            complex.AddProperty(prop2);
            complex.AddProperty(prop3);

            IEdmProperty ambiguous = complex.FindProperty("Foo");

            Assert.IsTrue(ambiguous.IsBad(), "Ambiguous binding is bad");

            Assert.AreEqual(EdmPropertyKind.None, ambiguous.PropertyKind, "No property kind.");
            Assert.AreEqual(complex, ambiguous.DeclaringType, "Correct declaring type.");
            Assert.IsTrue(ambiguous.Type.IsBad(), "Type is bad.");

            complex             = new EdmComplexType("Bar", "Foo");
            prop3               = new StubEdmStructuralProperty("Foo");
            prop3.DeclaringType = complex;
            complex.AddProperty(prop3);
            Assert.AreEqual(prop3, complex.FindProperty("Foo"), "Correct last item remaining.");
        }
Пример #2
0
        private StubEdmModel CreateDefinitionModel()
        {
            var model = new StubEdmModel();

            var barValueTerm = new StubValueTerm("", "bar")
            {
                Type = EdmCoreModel.Instance.GetInt32(true)
            };

            model.Add(barValueTerm);

            var bazValueTerm = new StubValueTerm("", "baz")
            {
                Type = EdmCoreModel.Instance.GetString(true)
            };

            model.Add(bazValueTerm);

            var p1 = new StubEdmStructuralProperty("p1")
            {
                Type = EdmCoreModel.Instance.GetString(true)
            };
            var p2 = new StubEdmStructuralProperty("p2")
            {
                Type = EdmCoreModel.Instance.GetString(true)
            };
            var foobazTypeTerm = new StubTypeTerm("", "foobaz")
            {
                p1, p2
            };

            model.Add(foobazTypeTerm);

            var p10 = new StubEdmStructuralProperty("p10")
            {
                Type = EdmCoreModel.Instance.GetString(true)
            };
            var bazfooTypeTerm = new StubTypeTerm("", "bazfoo")
            {
                p10
            };

            model.Add(bazfooTypeTerm);

            return(model);
        }
Пример #3
0
        public void Exception_From_Compute_Does_Not_Make_Cache_To_Fail_With_NullRefException()
        {
            var complexType = new EdmComplexType("Bar", "Foo");
            var property    = new StubEdmStructuralProperty(null)
            {
                DeclaringType = complexType
            };

            complexType.AddProperty(property);

            for (int i = 0; i < 10; i++)
            {
                try
                {
                    complexType.FindProperty(null);
                }
                catch (ArgumentNullException) { }
            }
        }
Пример #4
0
        public void TestElementInterfaceCriticalComplexTypeBaseType()
        {
            var expectedErrors = new EdmLibTestErrors()
            {
                { null, null, EdmErrorCode.InterfaceCriticalPropertyValueMustNotBeNull },
                { null, null, EdmErrorCode.InterfaceCriticalPropertyValueMustNotBeNull },
            };

            var baseComplexType = new StubEdmComplexType(null, null);
            var property        = new StubEdmStructuralProperty("")
            {
                DeclaringType = baseComplexType
            };

            baseComplexType.Add(property);
            this.ValidateElement(baseComplexType, expectedErrors);

            var derivedComplexType = new EdmComplexType("", "", baseComplexType, false);

            expectedErrors = new EdmLibTestErrors();
            this.ValidateElement(derivedComplexType, expectedErrors);
        }