Comments (4)
@whighsmith could you take a look at last comment and check if this is what you did?
from grpc-dotnet-enterprise.
@kkoziarski Yes... except I also removed the call to
services.Replace(ServiceDescriptor.Singleton<TContext, TContext>());
since the call to services.Replace in this case only "Adds" a descriptor (.Remove isn't called internally) and the InMemory DbContext will be added in the subclass (implementation of) GrpcServerApplicationFactoryBase when this.ConfigureTestServices(builder, services); is called.
On another note, I have also removed the dependency on DbContext (which moves all above source code to the subclass) out of the base classes all together since this testing infrastructure will be used with microservices and each microservice will have its own database which could mean a microservice could have a persistence layer that does not use DbContext but some other persistence mechanism and database/storage technology.
from grpc-dotnet-enterprise.
@kkoziarski You can also do the following in the subclass:
var dbContextOptionsDescriptor = services.FirstOrDefault(x => x.ServiceType == typeof(DbContextOptions<MyDbContext>));
services.Remove(dbContextOptionsDescriptor);
services.AddSingleton<DbContextOptions<MyDbContext>>(ctx =>
{
var optionsBuilder = new DbContextOptionsBuilder<MyDbContext>();
return optionsBuilder.UseInMemoryDatabase("IntegrationDatabase").Options;
});
since replacing DbContextOptions with the InMemoryDatabase option is what you are trying to achieve.
from grpc-dotnet-enterprise.
@whighsmith all are good points. I'm happy to accept your PR when you create it. Otherwise I'll try to do it in an undefined future.
from grpc-dotnet-enterprise.
Related Issues (1)
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 grpc-dotnet-enterprise.