Skip to content
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
wants to merge 29 commits into
base: master
Choose a base branch
from

Conversation

kccarter76
Copy link

@kccarter76 kccarter76 commented Jul 1, 2020

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.

@kccarter76
Copy link
Author

kccarter76 commented Jul 1, 2020

Base line file test\UnitTest\Microsoft.AspNet.OData.Test\PublicApi\Microsoft.AspNet.OData.PublicApi.bsl and output file D:\a\1\s\bin\Release\UnitTest\AspNet\Microsoft.AspNet.OData.PublicApi.out do not match, please check.
To update the baseline, please run:

copy /y "D:\a\1\s\bin\Release\UnitTest\AspNet\Microsoft.AspNet.OData.PublicApi.out" "test\UnitTest\Microsoft.AspNet.OData.Test\PublicApi\Microsoft.AspNet.OData.PublicApi.bsl"

I am going to need some help on your side to address this issue.

one thing I can try, may not work though

[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.2+2d84eb3141 (32-bit Desktop .NET 4.0.30319.42000)
[xUnit.net 00:00:00.59] Skipping: Microsoft.AspNet.OData.Test (could not find dependent assembly 'Microsoft.AspNet.OData.Test, Version=7.4.1')
No test matches the given testcase filter FullyQualifiedName=Microsoft.AspNet.OData.Test.ApplyTest.Apply_Works_WithNonODataJson|FullyQualifiedName=Microsoft.AspNet.OData.Test.ApplyTest.Apply_Works_WithODataJson|FullyQualifiedName=Microsoft.AspNet.OData.Test.ClrPropertyInfoAnnotationTest.Ctor_Throw... in D:\Source\home\WebApi\bin\Release\UnitTest\AspNet\Microsoft.AspNet.OData.Test.dll

build.cmd quick is not even executing the AspNet 4.5.2 framework version of the testing.

the key was to set the processor architecture from auto to x64 for any cpu

@marabooy marabooy added the Ready for review Use this label if a pull request is ready to be reviewed label Aug 11, 2020
@marabooy
Copy link
Member

marabooy commented Sep 3, 2020

@kccarter76 Thank you for your contribution, Kindly address the above comments.

@kccarter76
Copy link
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
Copy link
Member

@marabooy marabooy left a comment

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
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
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
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
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
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.

@kccarter76
Copy link
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.

@marabooy
Copy link
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
Copy link
Author

kccarter76 commented Jan 15, 2021

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
Copy link
Author

kccarter76 commented Jan 15, 2021

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

@@ -2354,9 +2354,48 @@ public enum Microsoft.AspNet.OData.Query.SelectExpandType : int {
Disabled = 2
}

<<<<<<< HEAD
Copy link
Member

@marabooy marabooy Jan 19, 2021

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
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
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

Any updates?

@drmcclelland
Copy link

Any updates @kccarter76 ?

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
5 participants