Exemple #1
0
        public void ODataComplexValueEdmValueTest()
        {
            IEdmModel model = Test.OData.Utils.Metadata.TestModels.BuildEdmValueModel();

            ODataComplexValue[] complexValues = new ODataComplexValue[]
            {
                // Empty complex value
                new ODataComplexValue()
                {
                    TypeName = "TestModel.EmptyComplexType"
                },

                // Complex value with a single primitive property
                new ODataComplexValue {
                    TypeName = "TestModel.SinglePrimitivePropertyComplexType", Properties = singlePrimitiveProperty
                },

                // Complex value with a single null property
                new ODataComplexValue {
                    TypeName = "TestModel.SinglePrimitivePropertyComplexType", Properties = singleNullProperty
                },

                // Complex value with all primitive typed properties
                new ODataComplexValue {
                    TypeName = "TestModel.AllPrimitivePropertiesComplexType", Properties = allPrimitiveProperties
                },

                // Complex value with complex property
                new ODataComplexValue {
                    TypeName = "TestModel.SingleComplexPropertyComplexType", Properties = complexProperty
                },

                // Complex value with nested complex property
                new ODataComplexValue {
                    TypeName = "TestModel.SingleComplexPropertyComplexType", Properties = nestedComplexProperty
                },

                // Complex value with primitive collection property
                new ODataComplexValue {
                    TypeName = "TestModel.SinglePrimitiveCollectionPropertyComplexType", Properties = primitiveCollectionProperty
                },

                // Complex value with complex collection property
                new ODataComplexValue {
                    TypeName = "TestModel.SingleComplexCollectionPropertyComplexType", Properties = complexCollectionProperty
                },

                // Complex value with different kinds of properties
                new ODataComplexValue {
                    TypeName = "TestModel.DifferentPropertyKindsComplexType", Properties = differentPropertyKinds
                },
            };

            this.CombinatorialEngineProvider.RunCombinations(
                complexValues,
                new bool[] { true, false },
                (complexValue, includeTypeReferences) =>
            {
                IEdmComplexTypeReference typeReference = null;
                if (includeTypeReferences)
                {
                    IEdmType schemaType = model.FindType(complexValue.TypeName);
                    this.Assert.IsNotNull(schemaType, "Expected to find type in the model.");
                    typeReference = (IEdmComplexTypeReference)schemaType.ToTypeReference(/*nullable*/ false);
                }

                IEdmValue complexEdmValue = ODataEdmValueUtils.CreateStructuredEdmValue(complexValue, typeReference);
                ODataEdmValueUtils.CompareValue(complexEdmValue, complexValue, this.Assert);
            });
        }
Exemple #2
0
        public void ODataEntryEdmValueTest()
        {
            IEdmModel model = Test.OData.Utils.Metadata.TestModels.BuildEdmValueModel();

            ODataEntry[] entries = new ODataEntry[]
            {
                // Entry with a single primitive property
                new ODataEntry {
                    TypeName = "TestModel.SinglePrimitivePropertyEntityType", Properties = singlePrimitiveProperty
                },

                // Entry with a single null property
                new ODataEntry {
                    TypeName = "TestModel.SinglePrimitivePropertyEntityType", Properties = singleNullProperty
                },

                // Entry with all primitive typed properties
                new ODataEntry {
                    TypeName = "TestModel.AllPrimitivePropertiesEntityType", Properties = allPrimitiveProperties
                },

                // Entry with complex property
                new ODataEntry {
                    TypeName = "TestModel.SingleComplexPropertyEntityType", Properties = complexProperty
                },

                // Entry with nested complex property
                new ODataEntry {
                    TypeName = "TestModel.SingleComplexPropertyEntityType", Properties = nestedComplexProperty
                },

                // Entry with primitive collection property
                new ODataEntry {
                    TypeName = "TestModel.SinglePrimitiveCollectionPropertyEntityType", Properties = primitiveCollectionProperty
                },

                // Entry with complex collection property
                new ODataEntry {
                    TypeName = "TestModel.SingleComplexCollectionPropertyEntityType", Properties = complexCollectionProperty
                },

                // Entry with different kinds of properties
                new ODataEntry {
                    TypeName = "TestModel.DifferentPropertyKindsEntityType", Properties = differentPropertyKinds
                },
            };

            this.CombinatorialEngineProvider.RunCombinations(
                entries,
                new bool[] { true, false },
                (entry, includeTypeReferences) =>
            {
                IEdmEntityTypeReference typeReference = null;
                IEdmEntitySet entitySet = null;
                if (includeTypeReferences)
                {
                    IEdmEntityType schemaType = (IEdmEntityType)model.FindType(entry.TypeName);
                    this.Assert.IsNotNull(schemaType, "Expected to find type in the model.");
                    typeReference = (IEdmEntityTypeReference)schemaType.ToTypeReference(/*nullable*/ false);

                    IEdmEntityContainer container = model.EntityContainer;
                    if (container != null)
                    {
                        entitySet = container.FindEntitySet(schemaType.Name + "Set");
                    }
                }

                IEdmValue entryEdmValue = ODataEdmValueUtils.CreateStructuredEdmValue(entry, entitySet, typeReference);
                ODataEdmValueUtils.CompareValue(entryEdmValue, entry, this.Assert);
            });
        }