public bool ComplexCollectionFunction(int key, [FromODataUri] EdmComplexObjectCollection addresses) { Assert.NotNull(addresses); IList <IEdmComplexObject> results = addresses.ToList(); Assert.Equal(2, results.Count); // #1 EdmComplexObject complex = results[0] as EdmComplexObject; Assert.Equal("NS.Address", complex.GetEdmType().FullName()); dynamic address = results[0]; Assert.NotNull(address); Assert.Equal("NE 24th St.", address.Street); Assert.Equal("Redmond", address.City); // #2 complex = results[1] as EdmComplexObject; Assert.Equal("NS.SubAddress", complex.GetEdmType().FullName()); address = results[1]; Assert.NotNull(address); Assert.Equal("LianHua Rd.", address.Street); Assert.Equal("Shanghai", address.City); Assert.Equal(9.9, address.Code); return(true); }
public bool EntityFunction(int key, [FromODataUri] EdmEntityObject customer) { Assert.NotNull(customer); dynamic result = customer; Assert.Equal("NS.Customer", customer.GetEdmType().FullName()); // entity call if (key == 9) { Assert.Equal(91, result.Id); Assert.Equal("John", result.Name); dynamic address = result.Location; EdmComplexObject addressObj = Assert.IsType <EdmComplexObject>(address); Assert.Equal("NS.Address", addressObj.GetEdmType().FullName()); Assert.Equal("NE 24th St.", address.Street); Assert.Equal("Redmond", address.City); } else { // entity reference call Assert.Equal(8, result.Id); Assert.Equal("Id", String.Join(",", customer.GetChangedPropertyNames())); Assert.Equal("Name,Location", String.Join(",", customer.GetUnchangedPropertyNames())); } return(true); }
public bool ComplexFunction(int key, [FromODataUri] EdmComplexObject address) { Assert.NotNull(address); dynamic result = address; Assert.Equal("NS.Address", address.GetEdmType().FullName()); Assert.Equal("NE 24th St.", result.Street); Assert.Equal("Redmond", result.City); return(true); }
public void CreateResource_CreatesEdmComplexObject_UnTypedMode() { // Arrange ODataDeserializerContext context = new ODataDeserializerContext { ResourceType = typeof(IEdmObject) }; // Act var resource = ODataComplexTypeDeserializer.CreateResource(_addressEdmType, context); // Assert EdmComplexObject complexObject = Assert.IsType <EdmComplexObject>(resource); Assert.Equal(_addressEdmType, complexObject.GetEdmType(), new EdmTypeReferenceEqualityComparer()); }
public void CreateResourceInstance_CreatesEdmComplexObject_IfTypeLessMode() { // Arrange var deserializer = new ODataResourceDeserializer(_deserializerProvider); ODataDeserializerContext readContext = new ODataDeserializerContext { Model = _readContext.Model, ResourceType = typeof(IEdmObject) }; // Act var result = deserializer.CreateResourceInstance(_addressEdmType, readContext); // Assert EdmComplexObject resource = Assert.IsType <EdmComplexObject>(result); Assert.Equal(_addressEdmType, resource.GetEdmType(), new EdmTypeReferenceEqualityComparer()); }
public bool CollectionEntityFunction(int key, [FromODataUri] EdmEntityObjectCollection customers) { Assert.NotNull(customers); IList <IEdmEntityObject> results = customers.ToList(); Assert.Equal(2, results.Count); // entities call if (key == 9) { // #1 EdmEntityObject entity = results[0] as EdmEntityObject; Assert.NotNull(entity); Assert.Equal("NS.Customer", entity.GetEdmType().FullName()); dynamic customer = results[0]; Assert.Equal(91, customer.Id); Assert.Equal("John", customer.Name); dynamic address = customer.Location; EdmComplexObject addressObj = Assert.IsType <EdmComplexObject>(address); Assert.Equal("NS.Address", addressObj.GetEdmType().FullName()); Assert.Equal("NE 24th St.", address.Street); Assert.Equal("Redmond", address.City); // #2 entity = results[1] as EdmEntityObject; Assert.Equal("NS.SpecialCustomer", entity.GetEdmType().FullName()); customer = results[1]; Assert.Equal(92, customer.Id); Assert.Equal("Mike", customer.Name); address = customer.Location; addressObj = Assert.IsType <EdmComplexObject>(address); Assert.Equal("NS.SubAddress", addressObj.GetEdmType().FullName()); Assert.Equal("LianHua Rd.", address.Street); Assert.Equal("Shanghai", address.City); Assert.Equal(9.9, address.Code); Assert.Equal(new Guid("883F50C5-F554-4C49-98EA-F7CACB41658C"), customer.Title); } else { // entity references call int id = 81; foreach (IEdmEntityObject edmObj in results) { EdmEntityObject entity = edmObj as EdmEntityObject; Assert.NotNull(entity); Assert.Equal("NS.Customer", entity.GetEdmType().FullName()); dynamic customer = entity; Assert.Equal(id++, customer.Id); Assert.Equal("Id", String.Join(",", customer.GetChangedPropertyNames())); Assert.Equal("Name,Location", String.Join(",", customer.GetUnchangedPropertyNames())); } } return(true); }