This commit is contained in:
Sam Xu 2014-12-22 18:00:47 +08:00
Родитель 6b6ed4387f
Коммит 099a84ed9a
6 изменённых файлов: 64 добавлений и 18 удалений

Просмотреть файл

@ -12,17 +12,17 @@
<DefineConstants>$(DefineConstants);ASPNETODATA;ASPNETWEBAPI</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.OData.Core, Version=6.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.OData.Core, Version=6.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.OData.Core.6.8.1\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.OData.Core.dll</HintPath>
<HintPath>..\..\packages\Microsoft.OData.Core.6.9.0\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.OData.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.OData.Edm, Version=6.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.OData.Edm, Version=6.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.OData.Edm.6.8.1\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.OData.Edm.dll</HintPath>
<HintPath>..\..\packages\Microsoft.OData.Edm.6.9.0\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.OData.Edm.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Spatial, Version=6.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.Spatial, Version=6.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Spatial.6.8.1\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.Spatial.dll</HintPath>
<HintPath>..\..\packages\Microsoft.Spatial.6.9.0\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.Spatial.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>

Просмотреть файл

@ -2,8 +2,8 @@
<packages>
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.OData.Core" version="6.8.1" targetFramework="net45" />
<package id="Microsoft.OData.Edm" version="6.8.1" targetFramework="net45" />
<package id="Microsoft.Spatial" version="6.8.1" targetFramework="net45" />
<package id="Microsoft.OData.Core" version="6.9.0" targetFramework="net45" />
<package id="Microsoft.OData.Edm" version="6.9.0" targetFramework="net45" />
<package id="Microsoft.Spatial" version="6.9.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
</packages>

Просмотреть файл

@ -1241,6 +1241,44 @@ namespace System.Web.OData.Routing
return functionSegment.GetParameterValue("Parameter");
}
[Fact]
public void CanParse_ComplexTypeAsFunctionParameter_ParametersAlias()
{
// Arrange
string complexAlias = "{\"@odata.type\":\"System.Web.OData.Routing.Address\",\"Street\":\"NE 24th St.\",\"City\":\"Redmond\"}";
// Act
ODataPath path = _parser.Parse(_model, _serviceRoot,
"RoutingCustomers(1)/Default.CanMoveToAddress(address=@address)?@address=" + complexAlias);
// Assert
Assert.Equal("~/entityset/key/function", path.PathTemplate);
BoundFunctionPathSegment functionSegment = (BoundFunctionPathSegment)path.Segments.Last();
object parameterValue = functionSegment.GetParameterValue("address");
ODataComplexValue address = Assert.IsType<ODataComplexValue>(parameterValue);
Assert.Equal("System.Web.OData.Routing.Address", address.TypeName);
}
[Fact]
public void CanParse_CollectionOfComplexTypeAsFunctionParameter_ParametersAlias()
{
// Arrange
string complexAlias = "[{\"Street\":\"NE 24th St.\",\"City\":\"Redmond\"},{\"Street\":\"Pine St.\",\"City\":\"Seattle\"}]";
// Act
ODataPath path = _parser.Parse(_model, _serviceRoot,
"RoutingCustomers(1)/Default.MoveToAddresses(addresses=@addresses)?@addresses=" + complexAlias);
// Assert
Assert.Equal("~/entityset/key/function", path.PathTemplate);
BoundFunctionPathSegment functionSegment = (BoundFunctionPathSegment)path.Segments.Last();
object parameterValue = functionSegment.GetParameterValue("addresses");
ODataCollectionValue addresses = Assert.IsType<ODataCollectionValue>(parameterValue);
Assert.Equal("Collection(System.Web.OData.Routing.Address)", addresses.TypeName);
}
[Theory]
[InlineData("unBoundWithoutParams", 1, "Edm.Boolean", "~/unboundfunction")]
[InlineData("unBoundWithoutParams()", 1, "Edm.Boolean", "~/unboundfunction")]

Просмотреть файл

@ -187,6 +187,14 @@ namespace System.Web.OData.Routing
overloadUnboundFunction.Parameter<int>("P2");
overloadUnboundFunction.Parameter<string>("P3");
var functionWithComplexTypeParameter =
builder.EntityType<RoutingCustomer>().Function("CanMoveToAddress").Returns<bool>();
functionWithComplexTypeParameter.Parameter<Address>("address");
var functionWithCollectionOfComplexTypeParameter =
builder.EntityType<RoutingCustomer>().Function("MoveToAddresses").Returns<bool>();
functionWithCollectionOfComplexTypeParameter.CollectionParameter<Address>("addresses");
return builder.GetEdmModel();
}

Просмотреть файл

@ -11,17 +11,17 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.OData.Core, Version=6.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.OData.Core, Version=6.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.OData.Core.6.8.1\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.OData.Core.dll</HintPath>
<HintPath>..\..\packages\Microsoft.OData.Core.6.9.0\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.OData.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.OData.Edm, Version=6.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.OData.Edm, Version=6.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.OData.Edm.6.8.1\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.OData.Edm.dll</HintPath>
<HintPath>..\..\packages\Microsoft.OData.Edm.6.9.0\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.OData.Edm.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Spatial, Version=6.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Reference Include="Microsoft.Spatial, Version=6.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Spatial.6.8.1\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.Spatial.dll</HintPath>
<HintPath>..\..\packages\Microsoft.Spatial.6.9.0\lib\portable-net40+sl5+wp8+win8+wpa\Microsoft.Spatial.dll</HintPath>
</Reference>
<Reference Include="Moq, Version=4.0.10827.0, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>

Просмотреть файл

@ -3,9 +3,9 @@
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.SelfHost" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.OData.Core" version="6.8.1" targetFramework="net45" />
<package id="Microsoft.OData.Edm" version="6.8.1" targetFramework="net45" />
<package id="Microsoft.Spatial" version="6.8.1" targetFramework="net45" />
<package id="Microsoft.OData.Core" version="6.9.0" targetFramework="net45" />
<package id="Microsoft.OData.Edm" version="6.9.0" targetFramework="net45" />
<package id="Microsoft.Spatial" version="6.9.0" targetFramework="net45" />
<package id="Moq" version="4.0.10827" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net45" />
<package id="xunit" version="1.9.1" targetFramework="net45" />