public ODataFeedSerializerTests()
        {
            _model       = SerializationTestsHelpers.SimpleCustomerOrderModel();
            _customerSet = _model.FindDeclaredEntityContainer("Default.Container").FindEntitySet("Customers");
            _customers   = new[] {
                new Customer()
                {
                    FirstName = "Foo",
                    LastName  = "Bar",
                    ID        = 10,
                },
                new Customer()
                {
                    FirstName = "Foo",
                    LastName  = "Bar",
                    ID        = 42,
                }
            };

            _customersType = new EdmCollectionTypeReference(
                new EdmCollectionType(
                    new EdmEntityTypeReference(
                        _customerSet.ElementType,
                        isNullable: false)),
                isNullable: false);

            _urlHelper    = new Mock <UrlHelper>(new HttpRequestMessage()).Object;
            _writeContext = new ODataSerializerContext()
            {
                EntitySet = _customerSet, UrlHelper = _urlHelper
            };
        }
        public ODataFeedSerializerTests()
        {
            _model       = SerializationTestsHelpers.SimpleCustomerOrderModel();
            _customerSet = _model.FindDeclaredEntityContainer("Default.Container").FindEntitySet("Customers");
            _model.SetAnnotationValue(_customerSet.ElementType, new ClrTypeAnnotation(typeof(Customer)));
            _customers = new[] {
                new Customer()
                {
                    FirstName = "Foo",
                    LastName  = "Bar",
                    ID        = 10,
                },
                new Customer()
                {
                    FirstName = "Foo",
                    LastName  = "Bar",
                    ID        = 42,
                }
            };

            _customersType = _model.GetEdmTypeReference(typeof(Customer[])).AsCollection();

            _writeContext = new ODataSerializerContext()
            {
                EntitySet = _customerSet, Model = _model
            };
        }
        public ODataCollectionSerializerTests()
        {
            _model       = SerializationTestsHelpers.SimpleCustomerOrderModel();
            _customerSet = _model.FindDeclaredEntityContainer("Default.Container").FindEntitySet("Customers");
            _edmIntType  = EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Int32, isNullable: false);
            _customer    = new Customer()
            {
                FirstName = "Foo",
                LastName  = "Bar",
                ID        = 10,
            };

            ODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();

            _collectionType = new EdmCollectionTypeReference(new EdmCollectionType(_edmIntType), isNullable: false);
            _serializer     = new ODataCollectionSerializer(serializerProvider);
        }
        public ODataComplexTypeSerializerTests()
        {
            _model   = SerializationTestsHelpers.SimpleCustomerOrderModel();
            _address = new Address()
            {
                Street  = "One Microsoft Way",
                City    = "Redmond",
                State   = "Washington",
                Country = "United States",
                ZipCode = "98052"
            };

            _addressType = _model.FindDeclaredType("Default.Address") as IEdmComplexType;

            ODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider(_model);

            _serializer = new ODataComplexTypeSerializer(new EdmComplexTypeReference(_addressType, isNullable: false), serializerProvider);
        }
Exemple #5
0
        public ODataEntityTypeSerializerTests()
        {
            _model       = SerializationTestsHelpers.SimpleCustomerOrderModel();
            _customerSet = _model.FindDeclaredEntityContainer("Default.Container").FindEntitySet("Customers");
            _customer    = new Customer()
            {
                FirstName = "Foo",
                LastName  = "Bar",
                ID        = 10,
            };

            ODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider(_model);

            _serializer   = new ODataEntityTypeSerializer(new EdmEntityTypeReference(_customerSet.ElementType, isNullable: false), serializerProvider);
            _urlHelper    = new Mock <UrlHelper>(new HttpRequestMessage()).Object;
            _writeContext = new ODataSerializerWriteContext(new ODataResponseContext())
            {
                EntitySet = _customerSet, UrlHelper = _urlHelper
            };
        }
Exemple #6
0
        public ODataComplexTypeSerializerTests()
        {
            _model   = SerializationTestsHelpers.SimpleCustomerOrderModel();
            _address = new Address()
            {
                Street  = "One Microsoft Way",
                City    = "Redmond",
                State   = "Washington",
                Country = "United States",
                ZipCode = "98052"
            };

            _addressType = _model.FindDeclaredType("Default.Address") as IEdmComplexType;
            _model.SetAnnotationValue(_addressType, new ClrTypeAnnotation(typeof(Address)));
            _addressTypeRef = _addressType.ToEdmTypeReference(isNullable: false).AsComplex();

            ODataSerializerProvider serializerProvider = new DefaultODataSerializerProvider();

            _serializer = new ODataComplexTypeSerializer(serializerProvider);
        }
Exemple #7
0
 public ODataEntityReferenceLinksSerializerTest()
 {
     _model       = SerializationTestsHelpers.SimpleCustomerOrderModel();
     _customerSet = _model.FindDeclaredEntityContainer("Default.Container").FindEntitySet("Customers");
 }