public DealersAndVehiclesServiceTests() { ServiceProvider serviceProvider = new ServiceCollection() .AddHttpClient() .AddSingleton <IApiService, ApiService>() .AddSingleton <IDataRetrievalService, DataRetrievalService>() .AddSingleton <IDealersAndVehiclesService, DealersAndVehiclesService>() .BuildServiceProvider(); _dealersAndVehiclesService = serviceProvider.GetService <IDealersAndVehiclesService>(); }
private static void ConfigureServices() { Log.Logger = new LoggerConfiguration().WriteTo.File("consoleapp.log").CreateLogger(); //Configuring services ServiceProvider serviceProvider = new ServiceCollection() .AddLogging(configure => configure.AddSerilog()) .AddHttpClient() .AddSingleton <IApiService, ApiService>() .AddSingleton <IDealersAndVehiclesService, DealersAndVehiclesService>() .AddSingleton <IDataRetrievalService, DataRetrievalService>() .BuildServiceProvider(); dealersAndVehiclesService = serviceProvider.GetService <IDealersAndVehiclesService>(); }