public static FakeMediaQueryService AddBlazorSize(this TestContextBase testContext) { testContext.RenderTree.Add <MediaQueryList>(); var mediaQueryServices = new FakeMediaQueryService(testContext); testContext.Services.AddSingleton <IMediaQueryService>(mediaQueryServices); return(mediaQueryServices); }
public static ILocalStorageService AddBlazoredLocalStorage(this TestContextBase context, Action <LocalStorageOptions> configure) { if (context is null) { throw new ArgumentNullException(nameof(context)); } var localStorageOptions = new LocalStorageOptions(); configure?.Invoke(localStorageOptions); localStorageOptions.JsonSerializerOptions.Converters.Add(new TimespanJsonConverter()); var localStorageService = new LocalStorageService(new InMemoryStorageProvider(), new SystemTextJsonSerializer(localStorageOptions)); context.Services.AddSingleton <ILocalStorageService>(localStorageService); return(localStorageService); }
public static ILocalStorageService AddBlazoredLocalStorage(this TestContextBase context, Action <LocalStorageOptions> configure) { if (context is null) { throw new ArgumentNullException(nameof(context)); } context.Services .AddSingleton <IJsonSerializer, SystemTextJsonSerializer>() .AddSingleton <IStorageProvider, InMemoryStorageProvider>() .AddSingleton <ILocalStorageService, LocalStorageService>() .AddSingleton <ISyncLocalStorageService, LocalStorageService>() .Configure <LocalStorageOptions>(configureOptions => { configure?.Invoke(configureOptions); configureOptions.JsonSerializerOptions.Converters.Add(new TimespanJsonConverter()); }); return(context.Services.GetService <ILocalStorageService>()); }
public static ILocalStorageService AddBlazoredLocalStorage(this TestContextBase context) => AddBlazoredLocalStorage(context, null);