public void Adding_temp_storage_should_configure_options_from_configure_options_callback() { var expected = new TempStorageOptions { RootPath = @"C:\Windows\Temp", MaxNumberOfBackgroundDisposalAttempts = 100, BackgroundDisposalInterval = TimeSpan.FromMinutes(5D) }; using var host = new HostBuilder() .ConfigureWebHost(webBuilder => webBuilder.UseTestServer() .ConfigureServices(services => services.AddTempStorage(options => { options.RootPath = expected.RootPath; options.MaxNumberOfBackgroundDisposalAttempts = expected.MaxNumberOfBackgroundDisposalAttempts; options.BackgroundDisposalInterval = expected.BackgroundDisposalInterval; }))) .Build(); var actual = host.Services.GetService <IOptions <TempStorageOptions> >(); actual.Value.Should().BeEquivalentTo(expected); }
private static void BackgroundDisposalConfiguration() { var options = new TempStorageOptions { MaxNumberOfBackgroundDisposalAttempts = 3, BackgroundDisposalInterval = TimeSpan.FromSeconds(30D) }; var tempStorage = new TempStorage(new OptionsWrapper <TempStorageOptions>(options)); }
private static void CreateTemporaryStorageWithCustomRootPath() { var options = new TempStorageOptions { RootPath = @"C:\Temp" }; using ITempStorage tempStorage = new TempStorage( new OptionsWrapper <TempStorageOptions>(options)); }
public TempStorageTests() { var options = new TempStorageOptions { RootPath = Guid.NewGuid().ToString("N"), BackgroundDisposalInterval = TimeSpan.FromSeconds(.1), MaxNumberOfBackgroundDisposalAttempts = 100 }; subject = new TempStorage(new OptionsWrapper <TempStorageOptions>(options)); }
public void Adding_temp_storage_should_configure_options_from_app_settings_json() { using var host = new HostBuilder() .ConfigureWebHost(webBuilder => webBuilder.UseTestServer() .ConfigureAppConfiguration(builder => builder.SetBasePath( Path.GetDirectoryName(typeof(TempStorageOptionsTests).Assembly.Location)) .AddJsonFile("appsettings.json")) .ConfigureServices(services => services.AddTempStorage())) .Build(); var actual = host.Services.GetService <IOptions <TempStorageOptions> >(); var expected = new TempStorageOptions { RootPath = @"C:\Temp", MaxNumberOfBackgroundDisposalAttempts = 2, BackgroundDisposalInterval = TimeSpan.FromSeconds(10D) }; actual.Value.Should().BeEquivalentTo(expected); }