Comments (5)
I'd like to help. Can you tell more about what we're trying to solve here?
We could customize the WebApplicationFactory for changing database setup during tests. More specifically, on integration tests. (This link tell us more about it: https://docs.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-3.1). Particularly, the way that it is now, what we're calling integration tests are actually a unit test of the repository with some fake dbContext. And, what we're calling component test is actually the integration test (at least for asp net core context)
from clean-architecture-manga.
Hey again @douglasramos π
The WebApplicationFactory would make the Component/Integration Tests easier to setup. It's a good idea to see it implemented here.
My initial thoughts was to design the dependency injection of "Real Implementations" like Entity Framework fallback into "In Memory" if it is running on test mode.
Also, features like Swagger, Authentication, API Versioning need some love segregating them.
from clean-architecture-manga.
Hi, @ivanpaulovich
Hmm, interesting. I can't think of a way to build this "switcher" inside of the WebAPI project, though. At least not an elegant way. How would the server itself have the knowledge that it is under test?
The way I see, the approach would be the WebApplicationFactory act as the switcher, changing EF Core implementation to in-memory fake ones. Unfortunately, that doesnβt cover unit test cases.
Let me know if you have any more thoughts on this :)
from clean-architecture-manga.
Hi @douglasramos,
Sorry for the delay in answering this topic.
Did you see the new CustomWebApplicationFactory.cs
? The current implementation tells the WebAPI to UseFake and it loads the in-memory implementation.
public sealed class CustomWebApplicationFactory : WebApplicationFactory<Startup>
{
protected override void ConfigureWebHost(IWebHostBuilder builder) => builder.ConfigureAppConfiguration(
(context, config) =>
{
config.AddInMemoryCollection(
new Dictionary<string, string> {["PersistenceModule:UseFake"] = "true"});
}).ConfigureServices(services =>
{
services.AddAuthentication(x =>
{
x.DefaultAuthenticateScheme = "Test";
x.DefaultChallengeScheme = "Test";
})
.AddScheme<AuthenticationSchemeOptions, TestAuthenticationHandler>(
"Test", options => { });
});
}
from clean-architecture-manga.
Closing as topic is too old.
from clean-architecture-manga.
Related Issues (20)
- Add ASP NET Identity
- Add MinVer and generate unique releases HOT 1
- Introduce HashCode struct into ValueObjects design HOT 1
- Withdrawal Concurrency HOT 2
- Failed to compile: Cannot find name 'connect'. TS2304 HOT 2
- Can Infrastructure layer reference direct a class on Domain layer? HOT 2
- On microservices, should the use case call the another service? HOT 4
- Executable specifications with Specflow HOT 2
- (Docker) issues running on Mac HOT 3
- Add Jaeger, Prometheus, Grafana and ELK docker containers
- [Question] How does the layering of this project match the clean architecture official diagram? HOT 1
- Multitenant support? HOT 1
- Environment Setup: docker_nginx doesn't not start - [emerg] 1#1: host not found in upstream HOT 2
- Repositories and Performance
- ./startup.sh failing on WebApi .Net 5 HOT 1
- Controller endpoint expects a ViewModel class as parameter (input)
- account-api won't start in Docker
- IdentityServer4 key rotation and management HOT 2
- Use Auth0 HOT 3
- Change IdentityServer to OpenIddict or implement both
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clean-architecture-manga.