public LPCReportServiceTest() { var services = new ServiceCollection(); var builder = new ConfigurationBuilder(); builder.SetBasePath(Directory.GetCurrentDirectory()); builder.AddJsonFile("appsettings.json").Build(); var connectionStringConfig = builder.Build(); var dbonnection = connectionStringConfig.GetConnectionString("SqlServer"); services.AddDbContext <NYCLandmarkContext>(options => options.UseSqlServer(dbonnection)); services.AddScoped <ILPCReportRepository, LPCReportRepository>(); services.AddScoped <ILPCReportService, LPCReportService>(); serviceProvider = services.BuildServiceProvider(); dbContext = serviceProvider.GetRequiredService <NYCLandmarkContext>(); lpcReportRepository = serviceProvider.GetRequiredService <ILPCReportRepository>(); lbcReportService = serviceProvider.GetRequiredService <ILPCReportService>(); AutoMapperConfiguration.Configure(); }
public LPCReportRepositoryTest() { var services = new ServiceCollection(); services.AddDbContext <NYCLandmarkContext>(options => options.UseNpgsql(@"User ID=nyclandmarks;Password=nyclandmarks;Server=192.168.99.100;Port=5432;Database=nyclandmarks;Integrated Security=true;Pooling=true;")); services.AddScoped <ILPCReportRepository, LPCReportRepository>(); serviceProvider = services.BuildServiceProvider(); dbContext = serviceProvider.GetRequiredService <NYCLandmarkContext>(); lpcReportRepository = serviceProvider.GetRequiredService <ILPCReportRepository>(); }
public LPCReportRepositoryTest() { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); var dbonnection = builder.GetConnectionString("SqlServer"); var serviceProvider = new ServiceCollection() .AddDbContext <NYCLandmarkContext>(options => options.UseSqlServer(dbonnection)) .AddScoped <ILPCReportRepository, LPCReportRepository>() .BuildServiceProvider(); serviceProvider.GetRequiredService <NYCLandmarkContext>(); _dbContext = serviceProvider.GetRequiredService <NYCLandmarkContext>(); _lpcReportRepository = serviceProvider.GetRequiredService <ILPCReportRepository>(); }
public LPCReportService(ILPCReportRepository lpcReportRepository) { this._lpcReportRepository = lpcReportRepository; }