I used the ODataPathParserTests for this scenario.
Scenario: An action is bound to an entity type. It returns a simple type.
Expected: segment's EntitySet should be 'Customers'
Actual: segment's EntitySet is null
Definition (NOTE: the commented line below was on purpose so that i can return a primitive type):
------------
builder.Entity<Customer>().ComplexProperty<Address>(c => c.Address);
//builder.Entity<Customer>().Action("GetRelatedCustomers").ReturnsCollectionFromEntitySet<Customer>("Customers");
builder.Entity<Customer>().Action("GetRelatedCustomers").Returns<int>();
Test:
------
[Fact]
public void CanParseActionBoundToEntitySegment()
{
// Arrange
string testUrl = "http://myservice/Customers(112)/GetRelatedCustomers";
string expectedText = "GetRelatedCustomers";
IEdmFunctionImport expectedEdmElement = GetModel().EntityContainers().First().FunctionImports().SingleOrDefault(p => p.Name == "GetRelatedCustomers");
IEdmEntitySet expectedSet = GetModel().EntityContainers().First().EntitySets().SingleOrDefault(e => e.Name == "Customers");
IEdmType expectedType = expectedEdmElement.ReturnType.Definition;
Uri uri = new Uri(testUrl);
Uri baseUri = new Uri("http://myservice/");
// Act
ODataPathSegment segment = GetParser().Parse(uri, baseUri, GetModel());
.....
Scenario: An action is bound to an entity type. It returns a simple type.
Expected: segment's EntitySet should be 'Customers'
Actual: segment's EntitySet is null
Definition (NOTE: the commented line below was on purpose so that i can return a primitive type):
------------
builder.Entity<Customer>().ComplexProperty<Address>(c => c.Address);
//builder.Entity<Customer>().Action("GetRelatedCustomers").ReturnsCollectionFromEntitySet<Customer>("Customers");
builder.Entity<Customer>().Action("GetRelatedCustomers").Returns<int>();
Test:
------
[Fact]
public void CanParseActionBoundToEntitySegment()
{
// Arrange
string testUrl = "http://myservice/Customers(112)/GetRelatedCustomers";
string expectedText = "GetRelatedCustomers";
IEdmFunctionImport expectedEdmElement = GetModel().EntityContainers().First().FunctionImports().SingleOrDefault(p => p.Name == "GetRelatedCustomers");
IEdmEntitySet expectedSet = GetModel().EntityContainers().First().EntitySets().SingleOrDefault(e => e.Name == "Customers");
IEdmType expectedType = expectedEdmElement.ReturnType.Definition;
Uri uri = new Uri(testUrl);
Uri baseUri = new Uri("http://myservice/");
// Act
ODataPathSegment segment = GetParser().Parse(uri, baseUri, GetModel());
.....