public void MiscQueryOptionTest()
        {
            ODataProperty        property        = this.TestsHelper.QueryProperty("Customers(1)/Numbers?$orderby=$it&$top=1", MimeType);
            ODataCollectionValue collectionValue = property.Value as ODataCollectionValue;

            if (collectionValue != null)
            {
                ODataCollectionValue expectedValue = new ODataCollectionValue()
                {
                    TypeName = "Collection(Edm.String)",
                    Items    = new[] { "012" }
                };
                ODataValueAssertEqualHelper.AssertODataValueAreEqual(expectedValue, collectionValue);
            }

            property        = this.TestsHelper.QueryProperty("Customers(1)/Numbers?$skip=1&$filter=contains($it,'a')", MimeType);
            collectionValue = property.Value as ODataCollectionValue;
            if (collectionValue != null)
            {
                ODataCollectionValue expectedValue = new ODataCollectionValue()
                {
                    TypeName = "Collection(Edm.String)",
                    Items    = new[] { "ayz" }
                };
                ODataValueAssertEqualHelper.AssertODataValueAreEqual(expectedValue, collectionValue);
            }
        }
 public void QueryCollectionOfEntitiesFromDeepLevelNavigation()
 {
     foreach (var mimeType in mimeTypes)
     {
         var entry  = this.QueryEntry("VipCustomer/Company/Employees(3)/Company/VipCustomer", mimeType, "Customer");
         var entry1 = this.QueryEntry("VipCustomer", mimeType, "Customer");
         if (!mimeType.Contains(MimeTypes.ODataParameterNoMetadata))
         {
             ODataValueAssertEqualHelper.AssertODataPropertiesAreEqual(entry.Properties, entry1.Properties);
         }
     }
 }
 public void QuerySingletonFromSingletonNavigation2()
 {
     foreach (var mimeType in mimeTypes)
     {
         var entry  = this.QueryEntry("VipCustomer/Company", mimeType, "Company");
         var entry1 = this.QueryEntry("Company", mimeType, "Company");
         if (!mimeType.Contains(MimeTypes.ODataParameterNoMetadata))
         {
             ODataValueAssertEqualHelper.AssertODataPropertiesAreEqual(entry.Properties, entry1.Properties);
         }
     }
 }
        public void BasicQueryOptionTest()
        {
            //$skip
            ODataProperty        property        = this.TestsHelper.QueryProperty("Customers(1)/Numbers?$skip=2", MimeType);
            ODataCollectionValue collectionValue = property.Value as ODataCollectionValue;

            if (collectionValue != null)
            {
                Assert.AreEqual(3, collectionValue.Items.Cast <object>().Count());
            }

            //$top
            property        = this.TestsHelper.QueryProperty("Customers(1)/Numbers?$top=3", MimeType);
            collectionValue = property.Value as ODataCollectionValue;
            if (collectionValue != null)
            {
                Assert.AreEqual(3, collectionValue.Items.Cast <object>().Count());
            }

            //$orderby
            property        = this.TestsHelper.QueryProperty("Customers(1)/Numbers?$orderby=$it", MimeType);
            collectionValue = property.Value as ODataCollectionValue;
            if (collectionValue != null)
            {
                ODataCollectionValue expectedValue = new ODataCollectionValue()
                {
                    TypeName = "Collection(Edm.String)",
                    Items    = new [] { "012", "111-111-1111", "310", "ayz", "bca" }
                };
                ODataValueAssertEqualHelper.AssertODataValueAreEqual(expectedValue, collectionValue);
            }

            //$filter
            property        = this.TestsHelper.QueryProperty("Customers(1)/Numbers?$filter=$it eq '012'", MimeType);
            collectionValue = property.Value as ODataCollectionValue;
            if (collectionValue != null)
            {
                ODataCollectionValue expectedValue = new ODataCollectionValue()
                {
                    TypeName = "Collection(Edm.String)",
                    Items    = new[] { "012" }
                };
                ODataValueAssertEqualHelper.AssertODataValueAreEqual(expectedValue, collectionValue);
            }
        }
        public void UpdateSingletonComplexProperty()
        {
            ODataResource complex0 = new ODataResource()
            {
                TypeName   = NameSpacePrefix + "Address",
                Properties = new[]
                {
                    new ODataProperty()
                    {
                        Name = "Street", Value = "1 Microsoft Way"
                    },
                    new ODataProperty()
                    {
                        Name = "City", Value = "London"
                    },
                    new ODataProperty()
                    {
                        Name = "PostalCode", Value = "98052"
                    }
                }
            };

            ODataNestedResourceInfo homeAddress0 = new ODataNestedResourceInfo()
            {
                Name = "HomeAddress", IsCollection = false
            };

            homeAddress0.SetAnnotation(complex0);

            ODataResource complex1 = new ODataResource()
            {
                TypeName   = NameSpacePrefix + "Address",
                Properties = new[]
                {
                    new ODataProperty()
                    {
                        Name = "Street", Value = "Zixing 999"
                    },
                    new ODataProperty()
                    {
                        Name = "City", Value = "Seattle"
                    },
                    new ODataProperty()
                    {
                        Name = "PostalCode", Value = "1111"
                    }
                }
            };
            ODataNestedResourceInfo homeAddress1 = new ODataNestedResourceInfo()
            {
                Name = "HomeAddress", IsCollection = false
            };

            homeAddress1.SetAnnotation(complex1);

            for (int i = 0; i < mimeTypes.Length; i++)
            {
                ODataResource currentHomeAddress;
                ODataResource updatedHomeAddress;

                object[] properties;
                if (i % 2 == 0)
                {
                    currentHomeAddress = complex0;
                    updatedHomeAddress = complex1;
                    properties         = new[] { homeAddress1 };
                }
                else
                {
                    currentHomeAddress = complex1;
                    updatedHomeAddress = complex0;
                    properties         = new[] { homeAddress0 };
                }
                List <ODataResource> entries = this.QueryEntry("VipCustomer", mimeTypes[i]);
                if (!mimeTypes[i].Contains(MimeTypes.ODataParameterNoMetadata))
                {
                    ODataValueAssertEqualHelper.AssertODataPropertyAndResourceEqual(currentHomeAddress, entries[0]);
                }

                this.UpdateEntry("Customer", "VipCustomer", mimeTypes[i], properties);

                List <ODataResource> updatedentries = this.QueryEntry("VipCustomer", mimeTypes[i]);
                if (!mimeTypes[i].Contains(MimeTypes.ODataParameterNoMetadata))
                {
                    ODataValueAssertEqualHelper.AssertODataPropertyAndResourceEqual(updatedHomeAddress, updatedentries[0]);
                }
            }
        }
        public void UpdateSingletonComplexProperty()
        {
            ODataComplexValue complexValue0 = new ODataComplexValue()
            {
                TypeName   = NameSpacePrefix + "Address",
                Properties = new[]
                {
                    new ODataProperty()
                    {
                        Name = "Street", Value = "1 Microsoft Way"
                    },
                    new ODataProperty()
                    {
                        Name = "City", Value = "London"
                    },
                    new ODataProperty()
                    {
                        Name = "PostalCode", Value = "98052"
                    }
                }
            };

            ODataProperty homeAddress0 = new ODataProperty()
            {
                Name = "HomeAddress", Value = complexValue0
            };

            ODataComplexValue complexValue1 = new ODataComplexValue()
            {
                TypeName   = NameSpacePrefix + "Address",
                Properties = new[]
                {
                    new ODataProperty()
                    {
                        Name = "Street", Value = "Zixing 999"
                    },
                    new ODataProperty()
                    {
                        Name = "City", Value = "Seattle"
                    },
                    new ODataProperty()
                    {
                        Name = "PostalCode", Value = "1111"
                    }
                }
            };
            ODataProperty homeAddress1 = new ODataProperty()
            {
                Name = "HomeAddress", Value = complexValue1
            };

            for (int i = 0; i < mimeTypes.Length; i++)
            {
                ODataProperty currentHomeAddress;
                ODataProperty updatedHomeAddress;

                if (i % 2 == 0)
                {
                    currentHomeAddress = homeAddress0;
                    updatedHomeAddress = homeAddress1;
                }
                else
                {
                    currentHomeAddress = homeAddress1;
                    updatedHomeAddress = homeAddress0;
                }
                ODataEntry entry = this.QueryEntry("VipCustomer", mimeTypes[i]);
                if (!mimeTypes[i].Contains(MimeTypes.ODataParameterNoMetadata))
                {
                    ODataValueAssertEqualHelper.AssertODataPropertyAreEqual((ODataProperty)entry.Properties.Single(p => p.Name == "HomeAddress"), currentHomeAddress);
                }

                var properties = new[] { updatedHomeAddress };
                this.UpdateEntry("Customer", "VipCustomer", mimeTypes[i], properties);

                ODataEntry updatedentry = this.QueryEntry("VipCustomer", mimeTypes[i]);
                if (!mimeTypes[i].Contains(MimeTypes.ODataParameterNoMetadata))
                {
                    ODataValueAssertEqualHelper.AssertODataPropertyAreEqual(updatedHomeAddress, (ODataProperty)updatedentry.Properties.Single(p => p.Name == "HomeAddress"));
                }
            }
        }