Exemplo n.º 1
0
        public AppFixture()
        {
            var services = new ServiceCollection();

            services.AddScoped <IRepository, Repository>();

            //Add Business Layer
            services.AddScoped <INodeBusiness, NodeBusiness>();
            services.AddSingleton <IBackgroundWorker, BackgroundWorker>();

            services.AddDbContext <ApplicationContext>(options =>
                                                       options.UseSqlServer(_connectionString));

            serviceProvider = services.BuildServiceProvider();

            var serviceScope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope();
            var context      = serviceProvider.GetService <ApplicationContext>();

            context.Database.Migrate();
            context.Seed();

            nodeBusiness = serviceProvider.GetRequiredService <INodeBusiness>();
        }
Exemplo n.º 2
0
 public NodesController(INodeBusiness nodeBusiness)
 {
     _business = nodeBusiness;
 }