Esempio n. 1
0
        public async Task CreateUpdateRequest_PreferredVerbPut_AllProperties_Put()
        {
            var preferredUpdateMethod = _session.Settings.PreferredUpdateMethod;

            try
            {
                _session.Settings.PreferredUpdateMethod = ODataUpdateMethod.Put;
                var requestWriter = new RequestWriter(_session, await _client.GetMetadataAsync <IEdmModel>(), null);
                var result        = await requestWriter.CreateUpdateRequestAsync("Products", "",
                                                                                 new Dictionary <string, object>() { { "ProductID", 1 } },
                                                                                 new Dictionary <string, object>()
                {
                    { "ProductID", 1 },
                    { "SupplierID", 2 },
                    { "CategoryID", 3 },
                    { "ProductName", "Chai" },
                    { "EnglishName", "Tea" },
                    { "QuantityPerUnit", "10" },
                    { "UnitPrice", 20m },
                    { "UnitsInStock", 100 },
                    { "UnitsOnOrder", 1000 },
                    { "ReorderLevel", 500 },
                    { "Discontinued", false },
                }, false);

                Assert.Equal("PUT", result.Method);
            }
            finally
            {
                _session.Settings.PreferredUpdateMethod = preferredUpdateMethod;
            }
        }
Esempio n. 2
0
        public async Task CreateUpdateRequest_NoPreferredVerb_PartialProperties_Patch()
        {
            var requestWriter = new RequestWriter(_session, await _client.GetMetadataAsync <IEdmModel>(), null);
            var result        = await requestWriter.CreateUpdateRequestAsync("Products", "",
                                                                             new Dictionary <string, object>() { { "ProductID", 1 } },
                                                                             new Dictionary <string, object>() { { "ProductName", "Chai" } }, false);

            Assert.Equal("PATCH", result.Method);
        }