public ProductRepositoryTests() { ContextOptions = MockDbContext.GetContextOptions(); MockDbContext.Seed(ContextOptions); MapperConfiguration = new MapperConfiguration(mc => mc.AddProfile(new ProductProfile())).CreateMapper().ConfigurationProvider; DbContext = new ExercisesDbContext(ContextOptions); }
public ProductServiceTests() { ContextOptions = MockDbContext.GetContextOptions(); MockDbContext.Seed(ContextOptions); MapperConfiguration = new MapperConfiguration(mc => { mc.AddProfile(new DataLayer.Profiles.ProductProfile()); mc.AddProfile(new BusinessLayer.Profiles.ProductProfile()); }).CreateMapper().ConfigurationProvider; DbContext = new ExercisesDbContext(ContextOptions); productRepository = new ProductRepository(DbContext, MapperConfiguration); }
public static void Seed(DbContextOptions <ExercisesDbContext> ContextOptions) { using (var context = new ExercisesDbContext(ContextOptions)) { context.Database.EnsureCreated(); if (context.products.Any() && context.shopperHistories.Any()) { return; } var products = LoadJson <Product>(@".\SampleData\products.json"); var shopperHistories = LoadJson <ShopperHistory>(@".\SampleData\shopperHistories.json"); context.products.AddRange(products); context.SaveChanges(); shopperHistories.ForEach(sh => { sh.product = context.products.Where(p => p.name == sh.productName).FirstOrDefault(); context.shopperHistories.Add(sh); context.SaveChanges(); }); } }
public MuscleGroupsService(ExercisesDbContext context) { this.context = context; }
public ExercisesService(ExercisesDbContext context, IBus publisher) : base(context) { this.context = context; this.publisher = publisher; }
public ProductRepository(ExercisesDbContext context, IConfigurationProvider config) { _context = context; _config = config; }
public UsersService(ExercisesDbContext context) { this.context = context; }
public TrainingSessionsService(ExercisesDbContext context, IBus publisher) : base(context) { this.context = context; this.publisher = publisher; }