-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create tests for GetNavigationSource
extension method
#1159
Conversation
[InlineData("VipCustomer/NS.SpecialCustomer", "VipCustomer", EdmNavigationSourceKind.Singleton)] | ||
[InlineData("Customers/$count", null, EdmNavigationSourceKind.None)] | ||
[InlineData("Customers(1)/Account/Amount/$value", null, EdmNavigationSourceKind.None)] | ||
[InlineData("$batch", null, EdmNavigationSourceKind.None)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to label these tests so as as to show which test case is being covered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We mostly use comments for such cases. Is that fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that works just as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wachugamaina @habbes FYI xunit/xunit#2532
@wachugamaina Curious, do you use NUnit in your repos? Does NUnit support parameterized tests with labels?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gathogojr thanks for the tip. That DisplayName
features in that thread will be part of xunit v3 which is not out yet.
@@ -290,6 +290,31 @@ public CustomersModelWithInheritance() | |||
getOrder.AddParameter("orderId", intType); | |||
model.AddElement(getOrder); | |||
|
|||
// functions with entity set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does this mean? bound to entity set? functions with entity set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functions that have an entity set path set. I think the entity set path expression is linked to the collection that contains the return type for functions that return an entity.
"GetTopCustomers", | ||
new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(customer, false))), | ||
isBound: false, | ||
entitySetPathExpression: customers.Path, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you have a path expression for an unbound function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I believe it applies for functions that return an entity or entity collection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the comment to reflect that this refers to the entity set path.
// unbound operation import with an entity set path should return the entity set | ||
[InlineData("GetTopCustomers()", "Customers", EdmNavigationSourceKind.EntitySet)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question @ElizabethOkerio asked. How does an unbound operation import have a navigation source?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that the function's returned values are entities from the specified entity set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@habbes How is such a function configured?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@habbes I guess:
modelBuilder.Function("GetTopCustomers").ReturnsCollectionFromEntitySet<Customer>("Customers");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I didn't know is that it returns the specified entity set as the navigation source...
test/Microsoft.AspNetCore.OData.Tests/ODataPathExtensionsTests.cs
Outdated
Show resolved
Hide resolved
test/Microsoft.AspNetCore.OData.Tests/ODataPathExtensionsTests.cs
Outdated
Show resolved
Hide resolved
test/Microsoft.AspNetCore.OData.Tests/ODataPathExtensionsTests.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments; otherwise LGTM
// property segment with a complex type, returns navigation source of previous segment | ||
[InlineData("Customers(1)/Account", "Customers", EdmNavigationSourceKind.EntitySet)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a property segment here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the property segment has a complex type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/Account
is the property segment. Account
is a complex property. And so the navigation source here is the navigation source of the previous segment, which is the key segment (1)
, whose navigation source is the Customers
entity set.
Co-authored-by: John Gathogo <john.gathogo@gmail.com>
69fc6ac
Co-authored-by: John Gathogo <john.gathogo@gmail.com>
Co-authored-by: John Gathogo <john.gathogo@gmail.com>
Related to issue #1118
Related to PR #1158
I want to refactor the
ODataPathExtensions.GetNavigationSource
extension method to improve its performance, but that method doesn't have tests. This PR adds tests covering all supported scenarios. This will make it safer to refactor without breaking existing behaviour.