public BaseTest()
        {
            // var serviceProvider = new ServiceCollection()
            ////.AddEntityFrameworkSqlServer()
            //.AddEntityFrameworkNpgsql()
            //.AddTransient<ITestService, TestService>()
            //.BuildServiceProvider();

            DbContextOptionsBuilder <StatusDatabaseContext> builder = new DbContextOptionsBuilder <StatusDatabaseContext>();
            var connectionString = "server=localhost;userid=root;password=12345678;database=StatusDatabase;";

            builder.UseMySql(connectionString);
            //.UseInternalServiceProvider(serviceProvider); //burası postgress ile sıkıntı çıkartmıyor, fakat mysql'de çalışmıyor test esnasında hata veriyor.

            _statusDatabaseContext = new StatusDatabaseContext(builder.Options);
            //_context.Database.Migrate();

            StatusSettings _statusSettings = new StatusSettings()
            {
                FileUploadFolderPath = "c:/"
            };
            IOptions <StatusSettings> statusOptions        = Options.Create(_statusSettings);
            IHttpContextAccessor      iHttpContextAccessor = new HttpContextAccessor {
                HttpContext = new DefaultHttpContext()
            };

            _statusService = new StatusService(_statusDatabaseContext, statusOptions, iHttpContextAccessor);
        }
 public StatusService(StatusDatabaseContext databaseContext, IOptions <StatusSettings> statusSettings, IHttpContextAccessor iHttpContextAccessor)
 {
     _statusRepository = new StatusRepository(databaseContext, statusSettings, iHttpContextAccessor);
 }
Exemple #3
0
 public ValuesController(ITestService testService, ProductDatabaseContext productDatabaseContext, IHostingEnvironment hostingEnvironment, StatusDatabaseContext statusDatabaseContext, IStatusService iStatusService)
 {
     _iStatusService         = iStatusService;
     _testService            = testService;
     _productDatabaseContext = productDatabaseContext;
     _hostingEnvironment     = hostingEnvironment;
 }