public IntegrationTestsBase(ITestOutputHelper output) : base(output) { var builder = new MvcWebApplicationBuilder <Startup>() .UseSolutionRelativeContentRoot("src/Exceptionless.Api") .ConfigureBeforeStartup(Configure) .ConfigureAfterStartup(RegisterServices) .UseApplicationAssemblies(); _server = builder.Build(); var settings = GetService <Newtonsoft.Json.JsonSerializerSettings>(); _serializer = GetService <ITextSerializer>(); _client = new FluentClient(new JsonContentSerializer(settings), _server.CreateHandler()) { BaseUri = new Uri(_server.BaseAddress + "api/v2") }; _httpClient = new HttpClient(_server.CreateHandler()) { BaseAddress = new Uri(_server.BaseAddress + "api/v2/") }; _configuration = GetService <ExceptionlessElasticConfiguration>(); _configuration.DeleteIndexesAsync().GetAwaiter().GetResult(); _configuration.ConfigureIndexesAsync(beginReindexingOutdated: false).GetAwaiter().GetResult(); }
protected override void ConfigureApplication(MvcWebApplicationBuilder <TStartup> builder) { base.ConfigureApplication(builder); builder.ConfigureBeforeStartup(services => { services.TryAddTransient <HtmlEncoder, HtmlTestEncoder>(); services.TryAddTransient <JavaScriptEncoder, JavaScriptTestEncoder>(); services.TryAddTransient <UrlEncoder, UrlTestEncoder>(); }); }
protected override TestServer CreateServer(MvcWebApplicationBuilder <TStartup> builder) { var originalCulture = CultureInfo.CurrentCulture; var originalUICulture = CultureInfo.CurrentUICulture; try { CultureInfo.CurrentCulture = new CultureInfo("en-GB"); CultureInfo.CurrentUICulture = new CultureInfo("en-US"); return(base.CreateServer(builder)); } finally { CultureInfo.CurrentCulture = originalCulture; CultureInfo.CurrentUICulture = originalUICulture; } }
/// <summary> /// Sets up an <see cref="IStartupFilter"/> that configures the <see cref="CultureReplacerMiddleware"/> at the /// beginning of the pipeline to change the <see cref="CultureInfo.CurrentCulture"/> and <see cref="CultureInfo.CurrentUICulture"/> /// of the thread so that they match the cultures in <paramref name="culture"/> and <paramref name="uiCulture"/> for the rest of the /// <see cref="HttpRequest"/>. /// </summary> /// <param name="culture">The culture to use when processing <see cref="HttpRequest"/>.</param> /// <param name="uiCulture">The UI culture to use when processing <see cref="HttpRequest"/>.</param> /// <returns>An instance of this <see cref="MvcWebApplicationBuilder{TStartup}"/></returns> public static MvcWebApplicationBuilder <TStartup> UseRequestCulture <TStartup>(this MvcWebApplicationBuilder <TStartup> builder, string culture, string uiCulture) where TStartup : class { if (culture == null) { throw new ArgumentNullException(nameof(culture)); } if (uiCulture == null) { throw new ArgumentNullException(nameof(uiCulture)); } builder.ConfigureBeforeStartup(services => { services.TryAddSingleton(new TestCulture { Culture = culture, UICulture = uiCulture }); services.TryAddEnumerable(ServiceDescriptor.Singleton <IStartupFilter, CultureReplacerStartupFilter>()); }); return(builder); }
protected override void ConfigureApplication(MvcWebApplicationBuilder <TStartup> builder) { builder.UseRequestCulture("en-GB", "en-US"); builder.ApplicationAssemblies.Clear(); builder.ApplicationAssemblies.Add(typeof(TStartup).GetTypeInfo().Assembly); }