-
Notifications
You must be signed in to change notification settings - Fork 473
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
Issue #1645 Interface Support Mock Testing #2215
Open
kccarter76
wants to merge
29
commits into
OData:master
Choose a base branch
from
kccarter76:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
34c5ec9
#1645 okay this is the easy part, now I get to hunt down where the in…
kccarter76 74a4d3a
Create dotnet-core.yml
kccarter76 97340aa
Update dotnet-core.yml
kccarter76 06f2992
Update dotnet-core.yml
kccarter76 4bc104a
Update dotnet-core.yml
kccarter76 7bd2fe9
Update dotnet-core.yml
kccarter76 4998dc8
Update dotnet-core.yml
kccarter76 9a1c79d
trying to get the github integration server building this code
kccarter76 c42f738
#1645
kccarter76 4f0872d
linux is very picky about names
kccarter76 a774ae3
Update dotnet-core.yml
kccarter76 8d08fbe
Rename ProductsCSDL.xml to ProductsCsdl.xml
kccarter76 090f996
no message
kccarter76 691a0ef
local test run completes succesful
kccarter76 f80cb57
Merge pull request #5 from kccarter76/dev/issue-1645
kccarter76 fa89897
#1645 unit test added and all unit tests passing
kccarter76 d6f43e4
Merge pull request #6 from kccarter76/dev/issue-1645
kccarter76 304be77
Delete dotnet-core.yml
kccarter76 8b1f5a2
remove the code that the designer did not
kccarter76 ed6d0b9
#1645 moved the interfaces to the shared project and adjusted things …
kccarter76 0c22e8e
#1645 updated the EnableQueryAttribute for AspNet
kccarter76 00da586
#1645 finally was able to generate the bsl
kccarter76 66e8f9a
update code files based on comments by marabooy
kccarter76 b8fc39e
per maraboy removed the notsupported exception
kccarter76 0198ea4
seperated the interface and class name space for this sut into sepera…
kccarter76 7ce2341
Merge branch 'master' of https://github.com/OData/WebApi into OData-m…
kccarter76 127a7d9
resolved conflicts
kccarter76 6567621
no message
kccarter76 ddffb5d
resolve conflct
kccarter76 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2,664 changes: 2,664 additions & 0 deletions
2,664
src/Microsoft.AspNet.OData.Shared/Common/SRResources1.Designer.cs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
151 changes: 151 additions & 0 deletions
151
src/Microsoft.AspNet.OData.Shared/Interfaces/IODataQueryOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
using Microsoft.AspNet.OData.Formatter; | ||
using Microsoft.AspNet.OData.Query; | ||
using Microsoft.AspNet.OData.Query.Validators; | ||
using System.Diagnostics.CodeAnalysis; | ||
using System.Linq; | ||
|
||
namespace Microsoft.AspNet.OData.Query | ||
{ | ||
/// <summary> | ||
/// This defines a composite OData query options that can be used to perform query composition. | ||
/// Currently this only supports $filter, $orderby, $top, $skip, and $count. | ||
/// </summary> | ||
[ODataQueryParameterBinding] | ||
[NonValidatingParameterBinding] | ||
public interface IODataQueryOptions | ||
{ | ||
/// <summary> | ||
/// Gets the given <see cref="ODataQueryContext"/> | ||
/// </summary> | ||
ODataQueryContext Context { get; } | ||
/// <summary> | ||
/// Gets the raw string of all the OData query options | ||
/// </summary> | ||
ODataRawQueryOptions RawValues { get; } | ||
/// <summary> | ||
/// Gets the <see cref="SelectExpandQueryOption"/>. | ||
/// </summary> | ||
SelectExpandQueryOption SelectExpand { get; } | ||
/// <summary> | ||
/// Gets the <see cref="ApplyQueryOption"/>. | ||
/// </summary> | ||
ApplyQueryOption Apply { get; } | ||
/// <summary> | ||
/// Gets the <see cref="FilterQueryOption"/>. | ||
/// </summary> | ||
FilterQueryOption Filter { get; } | ||
/// <summary> | ||
/// Gets the <see cref="OrderByQueryOption"/>. | ||
/// </summary> | ||
OrderByQueryOption OrderBy { get; } | ||
/// <summary> | ||
/// Gets the <see cref="SkipQueryOption"/>. | ||
/// </summary> | ||
SkipQueryOption Skip { get; } | ||
|
||
/// <summary> | ||
/// Gets the <see cref="SkipTokenQueryOption"/>. | ||
/// </summary> | ||
SkipTokenQueryOption SkipToken { get; } | ||
|
||
/// <summary> | ||
/// Gets the <see cref="TopQueryOption"/>. | ||
/// </summary> | ||
TopQueryOption Top { get; } | ||
|
||
/// <summary> | ||
/// Gets the <see cref="CountQueryOption"/>. | ||
/// </summary> | ||
CountQueryOption Count { get; } | ||
|
||
/// <summary> | ||
/// Gets or sets the query validator. | ||
/// </summary> | ||
ODataQueryValidator Validator { get; set; } | ||
|
||
/// <summary> | ||
/// Gets the <see cref="ETag"/> from IfMatch header. | ||
/// </summary> | ||
ETag IfMatch { get; } | ||
|
||
/// <summary> | ||
/// Gets the <see cref="ETag"/> from IfNoneMatch header. | ||
/// </summary> | ||
ETag IfNoneMatch { get; } | ||
|
||
/// <summary> | ||
/// Apply the individual query to the given IQueryable in the right order. | ||
/// </summary> | ||
/// <param name="query">The original <see cref="IQueryable"/>.</param> | ||
/// <returns>The new <see cref="IQueryable"/> after the query has been applied to.</returns> | ||
IQueryable ApplyTo(IQueryable query); | ||
|
||
/// <summary> | ||
/// Apply the individual query to the given IQueryable in the right order. | ||
/// </summary> | ||
/// <param name="query">The original <see cref="IQueryable"/>.</param> | ||
/// <param name="ignoreQueryOptions">The query parameters that are already applied in queries.</param> | ||
/// <returns>The new <see cref="IQueryable"/> after the query has been applied to.</returns> | ||
IQueryable ApplyTo(IQueryable query, AllowedQueryOptions ignoreQueryOptions); | ||
|
||
/// <summary> | ||
/// Apply the individual query to the given IQueryable in the right order. | ||
/// </summary> | ||
/// <param name="query">The original <see cref="IQueryable"/>.</param> | ||
/// <param name="querySettings">The settings to use in query composition.</param> | ||
/// <param name="ignoreQueryOptions">The query parameters that are already applied in queries.</param> | ||
/// <returns>The new <see cref="IQueryable"/> after the query has been applied to.</returns> | ||
IQueryable ApplyTo(IQueryable query, ODataQuerySettings querySettings, AllowedQueryOptions ignoreQueryOptions); | ||
|
||
/// <summary> | ||
/// Apply the individual query to the given IQueryable in the right order. | ||
/// </summary> | ||
/// <param name="query">The original <see cref="IQueryable"/>.</param> | ||
/// <param name="querySettings">The settings to use in query composition.</param> | ||
/// <returns>The new <see cref="IQueryable"/> after the query has been applied to.</returns> | ||
[SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity", Justification = "These are simple conversion function and cannot be split up.")] | ||
IQueryable ApplyTo(IQueryable query, ODataQuerySettings querySettings); | ||
|
||
/// <summary> | ||
/// Apply the individual query to the given IQueryable in the right order. | ||
/// </summary> | ||
/// <param name="entity">The original entity.</param> | ||
/// <param name="querySettings">The <see cref="ODataQuerySettings"/> that contains all the query application related settings.</param> | ||
/// <param name="ignoreQueryOptions">The query parameters that are already applied in queries.</param> | ||
/// <returns>The new entity after the $select and $expand query has been applied to.</returns> | ||
/// <remarks>Only $select and $expand query options can be applied on single entities. This method throws if the query contains any other | ||
/// query options.</remarks> | ||
object ApplyTo(object entity, ODataQuerySettings querySettings, AllowedQueryOptions ignoreQueryOptions); | ||
|
||
/// <summary> | ||
/// Applies the query to the given entity using the given <see cref="ODataQuerySettings"/>. | ||
/// </summary> | ||
/// <param name="entity">The original entity.</param> | ||
/// <param name="querySettings">The <see cref="ODataQuerySettings"/> that contains all the query application related settings.</param> | ||
/// <returns>The new entity after the $select and $expand query has been applied to.</returns> | ||
/// <remarks>Only $select and $expand query options can be applied on single entities. This method throws if the query contains any other | ||
/// query options.</remarks> | ||
object ApplyTo(object entity, ODataQuerySettings querySettings); | ||
|
||
/// <summary> | ||
/// Generates the Stable OrderBy query option based on the existing OrderBy and other query options. | ||
/// </summary> | ||
/// <returns>An order by query option that ensures stable ordering of the results.</returns> | ||
OrderByQueryOption GenerateStableOrder(); | ||
|
||
/// <summary> | ||
/// Check if the given query option is the supported query option. | ||
/// </summary> | ||
/// <param name="queryOptionName">The name of the query option.</param> | ||
/// <returns>Returns <c>true</c> if the query option is the supported query option.</returns> | ||
[SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "Need lower case string here.")] | ||
bool IsSupportedQueryOption(string queryOptionName); | ||
|
||
/// <summary> | ||
/// Validate all OData queries, including $skip, $top, $orderby and $filter, based on the given <paramref name="validationSettings"/>. | ||
/// It throws an ODataException if validation failed. | ||
/// </summary> | ||
/// <param name="validationSettings">The <see cref="ODataValidationSettings"/> instance which contains all the validation settings.</param> | ||
void Validate(ODataValidationSettings validationSettings); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/Microsoft.AspNet.OData.Shared/Interfaces/IODataQueryOptionsOfTEntity.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using Microsoft.AspNet.OData.Formatter; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Microsoft.AspNet.OData.Query | ||
{ | ||
/// <summary> | ||
/// This defines a composite OData query options that can be used to perform query composition. | ||
/// Currently this only supports $filter, $orderby, $top, $skip. | ||
/// </summary> | ||
[ODataQueryParameterBinding] | ||
public interface IODataQueryOptions<TEntity> | ||
: IODataQueryOptions | ||
{ | ||
/// <summary> | ||
/// Gets the <see cref="ETag{TEntity}"/> from IfMatch header. | ||
/// </summary> | ||
new ETag<TEntity> IfMatch { get; } | ||
|
||
/// <summary> | ||
/// Gets the <see cref="ETag{TEntity}"/> from IfNoneMatch header. | ||
/// </summary> | ||
new ETag<TEntity> IfNoneMatch { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 is more of a discussion than feedback: I came into this review not really knowing what query options were, and saw that the purpose was to convert it to an interface for mocking. I wondered to myself "how many ways really are there to implement a set of options? won't that just be a data type with a bunch of data type properties? there should just be a constructor overload where anything that needs to be mocked can be set directly instead". Seeing this interface, though, I see the many methods that are useful for the query options. I'm wondering, though, if it makes sense to separate those two things out. In this case, I would think the
ApplyTo
overloads belong on some other type rather than the options themselves. Do you have any thoughts on this?