-
Notifications
You must be signed in to change notification settings - Fork 24
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
chore: Replace Moq NuGet package with NSubstitute #370
chore: Replace Moq NuGet package with NSubstitute #370
Conversation
Codecov ReportPatch and project coverage have no change.
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. Additional details and impacted files@@ Coverage Diff @@
## develop #370 +/- ##
========================================
Coverage 69.52% 69.52%
========================================
Files 79 79
Lines 3491 3491
========================================
Hits 2427 2427
Misses 1064 1064
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
LGTM
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.
Just some comments
|
||
await store.Received().SaveInProgress( | ||
Arg.Is<JsonDocument>(t => | ||
t.ToString() == JsonSerializer.SerializeToDocument(product, new JsonSerializerOptions()).ToString()), |
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.
Instead of new JsonSerializerOptions()
should be Arg.Any<JsonSerializerOptions>
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.
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.
right if there is a Arg.Is
present all args should be specified, in that case should be Arg.Is<JsonSerializerOptions>
.Received(1) | ||
.SaveInProgress( | ||
Arg.Is<JsonDocument>(t => | ||
t.ToString() == JsonSerializer.SerializeToDocument("fake", new JsonSerializerOptions()) |
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.
Instead of new JsonSerializerOptions()
should be Arg.Any<JsonSerializerOptions>
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.
var eventArgs = new AspectEventArgs | ||
{ | ||
Name = methodName, | ||
Args = new object [] { } | ||
Args = Array.Empty<object>() |
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.
nice!
var provider = Substitute.For<IParameterProviderBaseHandler>(); | ||
provider.GetAsync<string>( | ||
key, | ||
Arg.Is<ParameterProviderConfiguration?>(x => x != null && x.MaxAge == duration), |
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.
It was Any implementation but now has a condition, why?
var provider = Substitute.For<IParameterProviderBaseHandler>(); | ||
provider.GetAsync<string>( | ||
key, | ||
Arg.Is<ParameterProviderConfiguration?>(x => x != null && x.ForceFetch), |
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.
All args were Any, now have conditions, why?
providerProxy.Verify(v => v.GetAsync(key, It.IsAny<ParameterProviderConfiguration?>()), Times.Once); | ||
powertoolsConfigurations.Verify(v => v.SetExecutionEnvironment(providerHandler), Times.Once); | ||
cacheManager.DidNotReceive().Get(key); | ||
await providerProxy.Received(1).GetAsync(key, Arg.Is<ParameterProviderConfiguration?>(x => x!.ForceFetch)); |
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.
All args were Any, now have conditions, why?
powertoolsConfigurations.Verify(v => v.SetExecutionEnvironment(providerHandler), Times.Once); | ||
cacheManager.Received(1).Get(key); | ||
await providerProxy.Received(1).GetMultipleAsync(key, Arg.Any<ParameterProviderConfiguration>()); | ||
cacheManager.Received(1).Set(key, Arg.Is<Dictionary<string, string?>>(x=> |
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.
Logic is very different than the current implementation. value Dictiionary is passed with Guids
cacheManager.Verify(v => v.Set(key, value, duration), Times.Once); | ||
powertoolsConfigurations.Verify(v => v.SetExecutionEnvironment(providerHandler), Times.Once); | ||
await providerProxy.Received(1).GetMultipleAsync(key, config); | ||
cacheManager.Received(1).Set(key, Arg.Is<Dictionary<string, string?>>(x=> |
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.
Logic is very different than the current implementation. value Dictiionary is passed with Guids
).ReturnsAsync(value); | ||
providerHandler.GetAsync<string>( | ||
key, | ||
Arg.Is<ParameterProviderConfiguration?>(x => x != null && !x.ForceFetch), |
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.
Args is any, why the change?
// Assert | ||
Assert.Equivalent("Root",entity.Name); | ||
Assert.Equal("Root", entity.Name); |
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.
I believe this change is ok, the types are both strings.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Issue number: #369
Summary
Removing the dependency to Moq library and replace it with NSubstitute Version="5.0.0"
Changes
All dependencies to Moq package are removed across all test projects Including all utilities as well as example test projects.
User experience
This won't change any use experience as only test projects are updated.
Checklist
Please leave checklist items unchecked if they do not apply to your change.
Is this a breaking change?
RFC issue number:
Checklist:
Acknowledgment
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.