예제 #1
0
        public BddDbContext GetDbContext()
        {
            var builder = new DbContextOptionsBuilder <BddDbContext>();

            InMemoryDatabaseRoot _inMemoryDatabaseRoot = new InMemoryDatabaseRoot();

            builder.UseInMemoryDatabase(Guid.NewGuid().ToString(), _inMemoryDatabaseRoot)
            .EnableServiceProviderCaching(false);

            var dbContext = new BddDbContext(builder.Options);

            dbContext.Database.EnsureCreated();
            return(dbContext);
        }
 public ProductServiceTest()
 {
     _dbContext      = GetDbContext();
     _productService = new ProductService(_productRepositoryMock.Object, _userRepositoryMock.Object, _dbContext);
 }
예제 #3
0
 public ProductRepository(BddDbContext dbContext)
 {
     _dbContext = dbContext;
 }
예제 #4
0
 public UserRepository(BddDbContext dbContext)
 {
     _dbContext = dbContext;
 }
예제 #5
0
 public ProductService(IProductRepository productRepository, IUserRepository userRepository, BddDbContext dbContext)
 {
     _productRepository = productRepository;
     _userRepository    = userRepository;
     _dbContext         = dbContext;
 }