Tests | Remove DataAttribute Subclasses#4427
Conversation
…oreProviderShould.cs and SqlColumnEncryptionCngProviderShould.cs
There was a problem hiding this comment.
Pull request overview
This PR refactors a few Always Encrypted functional tests to stop using nested DataAttribute subclasses for theory data (unsupported by xUnit 3), replacing them with MemberData backed by static TheoryData properties. This is aligned with the repo’s longer-term effort to make an eventual xUnit 3 migration easier once net462 test support is removed.
Changes:
- Replaced custom
[DataAttribute]-based theory data with[MemberData]across CSP/CNG/CertificateStore provider test suites. - Introduced static
TheoryData<...>properties colocated with the theories that consume them. - Removed the old nested
DataAttributeclasses.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/SqlColumnEncryptionCspProviderShould.cs | Switches invalid-parameter theory data to MemberData with static TheoryData. |
| src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/SqlColumnEncryptionCngProviderShould.cs | Switches invalid-parameter theory data to MemberData with static TheoryData. |
| src/Microsoft.Data.SqlClient/tests/FunctionalTests/AlwaysEncryptedTests/SqlColumnEncryptionCertificateStoreProviderShould.cs | Switches multiple theory data sources (decrypt/encrypt/sign/AED reversal) to MemberData with static TheoryData. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4427 +/- ##
==========================================
- Coverage 65.78% 65.62% -0.17%
==========================================
Files 286 284 -2
Lines 43696 72384 +28688
==========================================
+ Hits 28745 47500 +18755
- Misses 14951 24884 +9933
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Description
Eventually, we'd like to upgrade to xUnit 3. The biggest showstopper for this is that xUnit 3 does not support net462. But, there are smaller tasks we could address to make upgrading easier once we no longer support net462 (or at least don't support in in our tests). This PR is one of those small upgrade tasks. A small collection of tests were using implementing theory data via nested classes that inherited from
DataAttribute. This is not supported in xUnit 3. To resolve this, I've switched these instances to the commonly usedMemberDataattribute usage, and made the nested classes into static properties next to the tests that use them.Yes, the lines are very long. I didn't attempt to clean them up because I personally feel the longer lines are more readable than trying to chop the lines.
Testing
These are non-functional changes to tests, so PR validation should be sufficient.