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.
Issues
This pull request fixes #xxx.
Description
This PR updates the common data sources. It adds logic for resetting the data source and creating a copy of the data source by each test to avoid data corruption in cases where tests run in parallel,
It is important to note that
xunit
tests in different classes run in parallel. This therefore means that if they are updating the same data source then we'll run into data corruption issues which necessitated the tests in 7.x to useTestPriority
in running the tests.To fix this, I've added an action for the different data sources that creates a copy of the original data. This means that each test class will implement this action. The implementation will then be included in the test class's constructor. This will mean that each test will work on a new copy of data every other time and we won't need to use the
TestPriority
attribute that we were using before. This will also make it easy to add assertions to assert that what we are testing is correct. Most of the tests that we are porting didn't have the assertions as the data was corrupted as it was not being reset correctly.For creating copies, I'm using
System.Text.Json
library which does deep copies as the source data has some deep nesting. The other options for copying these data were a bit manual, others depended on reflection hence why I decided to use this library.Checklist (Uncheck if it is not completed)
Additional work necessary
If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.