Exemple #1
0
 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);
 }
Exemple #3
0
        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();
                });
            }
        }
Exemple #4
0
 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;
 }
Exemple #7
0
 public UsersService(ExercisesDbContext context)
 {
     this.context = context;
 }
 public TrainingSessionsService(ExercisesDbContext context, IBus publisher)
     : base(context)
 {
     this.context   = context;
     this.publisher = publisher;
 }