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

Replace Moq with NSubstitute #1903

Merged
merged 18 commits into from
Jun 14, 2024
Merged

Conversation

cristian-ambrosini-sonarsource
Copy link
Contributor

Reviewer: each commit is replacing moq in a single project

Copy link
Contributor

@pavel-mikula-sonarsource pavel-mikula-sonarsource left a comment

Choose a reason for hiding this comment

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

Some adjustments and rework of the Protected trick

@github-actions github-actions bot moved this from Review in progress to In progress in S4NET Kanban Apr 23, 2024
@CristianAmbrosini
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

@CristianAmbrosini
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

@CristianAmbrosini
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

Copy link
Contributor

@pavel-mikula-sonarsource pavel-mikula-sonarsource left a comment

Choose a reason for hiding this comment

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

One more round on the handler mock

Comment on lines 430 to 433
new(async (request, cancellationToken) => request.RequestUri switch
{
var url when url == new Uri(cacheFullUrl) => new HttpResponseMessage
{
Copy link
Contributor

Choose a reason for hiding this comment

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

What about making there a fuent API like

new HttpMessageHandlerMock()
    .AddResponse(URL, new StringContent(...)),
    .AddResponse(URL, ....)

and then, the method would just iterate a list of responses and return 404 otherwise.

A token could be a ctor parameter.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's a bit of an over-engineered solution for the usage that we require, open to discussing it

Copy link
Contributor

Choose a reason for hiding this comment

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

We're building framework that will be reused in the future. Just the next sprint about bootstrapper will use this again. The problem I see is that the mock is too hard to use and produces code that is too hard to read (constructor inside ternary inside lambda inside constructor).

Please create a follow up PR that will change this.

@github-actions github-actions bot moved this from Review in progress to In progress in S4NET Kanban May 16, 2024
@CristianAmbrosini
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

@CristianAmbrosini
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

@CristianAmbrosini
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

@CristianAmbrosini
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

@CristianAmbrosini
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

@CristianAmbrosini
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

Copy link
Contributor

@pavel-mikula-sonarsource pavel-mikula-sonarsource left a comment

Choose a reason for hiding this comment

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

I don't know where the regex came from

S4NET Kanban automation moved this from In progress to Review in progress Jun 12, 2024
@github-actions github-actions bot moved this from Review in progress to In progress in S4NET Kanban Jun 12, 2024
@CristianAmbrosini
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

Copy link

sonarcloud bot commented Jun 13, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
2 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

@pavel-mikula-sonarsource pavel-mikula-sonarsource left a comment

Choose a reason for hiding this comment

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

LGTM

S4NET Kanban automation moved this from In progress to Reviewer approved Jun 14, 2024
@pavel-mikula-sonarsource pavel-mikula-sonarsource merged commit 387b64a into master Jun 14, 2024
25 checks passed
S4NET Kanban automation moved this from Reviewer approved to Done Jun 14, 2024
@pavel-mikula-sonarsource pavel-mikula-sonarsource deleted the cristian/replace-moq branch June 14, 2024 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
S4NET Kanban
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants