Beispiel #1
0
        public ProfileManagerTest()
        {
            var serviceProvider = new ServiceCollection()
                                  .AddDbContext <FoodAppContext>(options =>
                                                                 options.UseInMemoryDatabase($"{nameof(ProfileManagerTest)}_Db")
                                                                 .UseInternalServiceProvider(
                                                                     new ServiceCollection()
                                                                     .AddEntityFrameworkInMemoryDatabase()
                                                                     .BuildServiceProvider()))
                                  .AddScoped(typeof(IRepositoryManager <>), typeof(RepositoryManager <>))
                                  .BuildServiceProvider();

            _foodAppContext    = serviceProvider.GetRequiredService <FoodAppContext>();
            _profileRepository = serviceProvider.GetRequiredService <IRepositoryManager <Profile> >();

            _profileManager = new ProfileManager(_profileRepository);
        }
 public ProductController()
 {
     _context = new FoodAppContext();
 }
Beispiel #3
0
 public MainVM(FoodAppContext context, IDataRepository repo)
 {
     _dbContext     = context;
     _repo          = repo;
     TestingCommand = new TestingCommand(this);
 }
Beispiel #4
0
 public RepositoryManager(FoodAppContext context)
 {
     _context = context ?? throw new ArgumentNullException(nameof(context));
     _dbSet   = context.Set <T>();
 }