Skip to main content
4 votes

.Net 8 XUnit: Should my tests use real data or how to mock MySql with CQRS?

Given that we have easy spin up of databases in containers these days I think the best solution for testing is to spin up a real database and throw it away afterwards. You can go further and use ...
Ewan's user avatar
  • 77.5k
4 votes
Accepted

.Net 8 XUnit: Should my tests use real data or how to mock MySql with CQRS?

The answer here is as often "depends what you're trying to test". If you're trying to unit test an edge case (e.g. that the application does not crash if the query errors), you almost ...
Philip Kendall's user avatar
1 vote
Accepted

.Net 8 XUnit: How to mock MySql in a CQRS API using integration tests?

OK so to summarise the EF tests Lab setup is not shown. But we can see a WebApplicationFactory is passed in and the IVdcRepository<Job> implementation is extracted from the DI container and the ...
Ewan's user avatar
  • 77.5k
1 vote

.Net 8 XUnit: How to mock MySql in a CQRS API using integration tests?

What I ended up doing is to mock the interface who has the MySql methods and inject the expected data from the Lab class, then in the test I call the controller and compare result with the result get ...
Diego Perez's user avatar
1 vote

.Net 8 XUnit: How to mock MySql in a CQRS API using integration tests?

Integration test use real data and real databases to ensure that your components communicate across boundaries. If you are doing an integration test, you need to figure out how to make that work, not ...
jmoreno's user avatar
  • 11k
1 vote
Accepted

Reduce Code Repetition for a Simple CQRS

Stating the bleeding obvious here: promoting reusability entails introducing an additional abstraction which allows for said reuse. Less obvious is that there's a difference between theoretical ...
Flater's user avatar
  • 53k

Only top scored, non community-wiki answers of a minimum length are eligible