Skip to content

Issue #1645 Interface Support Mock Testing#2215

Open
kccarter76 wants to merge 465 commits into
OData:masterfrom
kccarter76:master
Open

Issue #1645 Interface Support Mock Testing#2215
kccarter76 wants to merge 465 commits into
OData:masterfrom
kccarter76:master

Conversation

@kccarter76

@kccarter76 kccarter76 commented Jul 1, 2020

Copy link
Copy Markdown

Issues

Feature enhancement resolves #1645

Description

added the ability to use an interface IODataQueryOptions as a parameter on a controller method.

Checklist (Uncheck if it is not completed)

  • Test cases added
  • Build and test with one-click build and test script passed

Additional work necessary

feature needs to still be documented and the issue #1645 updated with Docs Needed.

biaol-odata and others added 30 commits May 30, 2018 16:26
While trying to add complex types to the test model for SelectExpandTests, I
ran into an issue with EF where some existing tests failed due to EF's own EDM
model validation. This was happening because it assumes the new complex type
is actually an entity type, even though it doesn't have a key.

My solution is just to factor out the EF-related tests into their own class,
SelectExpandEFTests. This should allow the addition of complex types to the
SelectExpandTests test model without breaking any of the existing tests.
In the spirit of TDD, I wrote a failing test before attempting to fix this
issue: OData#196

Unfortunately, the fix looks more like a large and complex feature than just
a simple bug fix, and I don't have bandwidth to take it on right now.
However, the test may still be useful for the next person to make the
attempt.
* Update ODL dependencies to 7.5.0
    - Update package versions.
    - Revert test workaround for the pending 7.5.0 release.
    - Disable obsolete warnings for AggregateTransformationNode.Expressions introduced in v7.5.0

* Update dependencies on classic side and performance.sln.
* Adding support to entity set aggregations.
* Enable IN operator for $filter. Supported collections include paren-defined collections, property collections, and navigation properties.
* Added test cases to accompany change.
* downgrade the newtonsoft.json version to 6.0.4 for classic

* change the newtonsoft.json version in classic test
@kccarter76 kccarter76 requested a review from marabooy November 17, 2020 20:15
@kccarter76

Copy link
Copy Markdown
Author

I do not have write access to the destination branch. the conflicts that are currently listed are a product of natural development and where not present at the time this was completed. I may not have the time available to address.

@marabooy marabooy added this to the 7.5.2 milestone Nov 24, 2020

@marabooy marabooy left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, I didn't find any apparent issues with backwards compatibility.
@kccarter76 Do let me know when you are ready to get this merged in and any help you require.

}
}

namespace Microsoft.AspNet.OData.Test.Formatter.Interface

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split this to two namespaces for consistency.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about what you are asking here? been awhile since looking at this code.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are asking about the sut class version in a class namespace and the interface implementation in an interface namespace. is that correct?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might be best to split into two separate files to simplify reading the code base.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need more eyes on this, since I have been unable to resolve the issue with the unit tests not running. @marabooy, I have sent you a collaboration request. I have hit a road block and the work crews appear to be on a permanent coffee break.

RamjotSingh and others added 7 commits December 9, 2020 11:16
…2362)

* Enabling query validation EnableQuery before action execution

* Adding test

* Name updates.

* Adding #if for NetCore tests

* Adding code to throw BadRequest

* Fixing issues

* Fixing the public API file

* Adding fixes for tests

* Fixing generic type code

* Adding support for ActionResult<>

* Taking PR comments

* Taking PR comments

* Taking PR comment

* Taking PR comments

* Just retrying build
* Fix MergeIndividualAndBatchPreferences method
for same Prefer headers case (bug with an unnecessary comma at the end of line)

* Add test merging same Prefer header while processing batch.

Co-authored-by: Tsar Nikolay <nsmirnov@ics.perm.ru>
@kccarter76 kccarter76 requested a review from marabooy January 14, 2021 22:12
@kccarter76

Copy link
Copy Markdown
Author

to resolve the above conflicts, it would be best to collaborate. I am not sure what needs to be kept and merge what is needed to support the interface. EnableQueryAttribute was straight forward. however the others not so much.

…Data#2397)

* Moving request query data to HttpContext

* Adding one more E2E test

* Adding tests for parallelization check
@marabooy

Copy link
Copy Markdown
Member

@kccarter76 the BSL updates can be done by running the respective PublicApi tests and copying over the new file.
Checkout the public api test linked here

@kccarter76

kccarter76 commented Jan 15, 2021

Copy link
Copy Markdown
Author

I am missing code for RequestQueryData. I may need to merge/pull the current master into my github fork. okay my EnableQueryAttribute is really out of sync with the base master and when I try to create a pull request from webApi:master to kccarter76webapi:master.

…aster

# Conflicts:
#	src/Microsoft.AspNetCore.OData/EnableQueryAttribute.cs
#	test/UnitTest/Microsoft.AspNet.OData.Test/PublicApi/Microsoft.AspNet.OData.PublicApi.bsl
#	test/UnitTest/Microsoft.AspNetCore.OData.Test/PublicApi/Microsoft.AspNetCore.OData.PublicApi.bsl
#	test/UnitTest/Microsoft.AspNetCore.OData.Test/PublicApi/Microsoft.AspNetCore3x.OData.PublicApi.bsl
@kccarter76

kccarter76 commented Jan 15, 2021

Copy link
Copy Markdown
Author

is this being addressed in the AspNet solution:

Severity Code Description Project File Line Suppression State
Warning CA0507 Post-build Code Analysis (FxCopCmd.exe) has been deprecated in favor of FxCop analyzers, which run during build. Refer to https://aka.ms/fxcopanalyzers to migrate to FxCop analyzers. Active

this exception is preventing me from updating 'Microsoft.AspNet.OData.PublicApi.bsl'

Severity Code Description Project File Line Suppression State
Error CA0001 CA0001 : Exception of type 'Phx.FatalError' was thrown. Active

was able to git this worked around by not running code analysis. however, the x unit tests are not running again and the work around from before is not working.

microsoft/vstest#1220

image

Disabled = 2
}

<<<<<<< HEAD

@marabooy marabooy Jan 19, 2021

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kindly fix the merge result here. I will check with someone on the team to see what can be done to help.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

working on it, currently dealing with an issue where VS 2019 16.8 will not run unit tests on local machine. see tail end of microsoft/vstest#1220

/// </summary>
[ODataQueryParameterBinding]
[NonValidatingParameterBinding]
public interface IODataQueryOptions

Copy link
Copy Markdown
Contributor

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?

@BabaDorin

Copy link
Copy Markdown

Any updates?

@drmcclelland

Copy link
Copy Markdown

Any updates @kccarter76 ?

@xuzhg xuzhg force-pushed the master branch 2 times, most recently from 4c43a84 to ddfd3dd Compare May 29, 2026 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Use this label if a pull request is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support: Add interface to create ODataQueryOptions via a mock framework