コード例 #1
0
ファイル: AmbiguousTypeTests.cs プロジェクト: pbvs/odata.net
        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 static (IEdmModel, IEdmStructuredType) GetOData()
        {
            EdmModel       model   = new EdmModel();
            EdmComplexType address = new EdmComplexType("NS", "Address");

            address.AddStructuralProperty("City", EdmPrimitiveTypeKind.String);
            address.AddStructuralProperty("Street", EdmPrimitiveTypeKind.String);
            model.AddElement(address);

            model.SetAnnotationValue(address, new ClrTypeAnnotation(typeof(JAddress)));

            model.SetAnnotationValue(address.FindProperty("Street"),
                                     new ClrPropertyInfoAnnotation(typeof(JAddress).GetProperty("Street")));

            return(model, address);
        }
コード例 #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) { }
            }
        }