From 3e10688d125dd40b8ff9ecec7f14edc92154081e Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Fri, 19 Jul 2019 12:33:08 -0700 Subject: [PATCH] Attempt to fix bind tests for non-en-US While it's definitly intended for `@bind` to have culture-sensitive output for most cases, we want the tests to behave consistently for all developers. So this is an attempt to use a fixed culture for all of our testing. --- src/Components/test/testassets/BasicTestApp/Program.cs | 4 ++++ src/Components/test/testassets/TestServer/Startup.cs | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Components/test/testassets/BasicTestApp/Program.cs b/src/Components/test/testassets/BasicTestApp/Program.cs index 5e85aca979..cebb226e7c 100644 --- a/src/Components/test/testassets/BasicTestApp/Program.cs +++ b/src/Components/test/testassets/BasicTestApp/Program.cs @@ -1,6 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using System.Globalization; using Microsoft.AspNetCore.Blazor.Hosting; namespace BasicTestApp @@ -9,6 +10,9 @@ namespace BasicTestApp { public static void Main(string[] args) { + // We want the culture to be en-US so that the tests for bind can work consistently. + CultureInfo.CurrentCulture = new CultureInfo("en-US"); + CreateHostBuilder(args).Build().Run(); } diff --git a/src/Components/test/testassets/TestServer/Startup.cs b/src/Components/test/testassets/TestServer/Startup.cs index c7024786d4..4aba67f9f9 100644 --- a/src/Components/test/testassets/TestServer/Startup.cs +++ b/src/Components/test/testassets/TestServer/Startup.cs @@ -5,6 +5,7 @@ using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Localization; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -76,7 +77,12 @@ namespace TestServer options.AddSupportedCultures("en-US", "fr-FR"); options.AddSupportedUICultures("en-US", "fr-FR"); - // Cookie culture provider is included by default. + // Cookie culture provider is included by default, but we want it to be the only one. + options.RequestCultureProviders.Clear(); + options.RequestCultureProviders.Add(new CookieRequestCultureProvider()); + + // We want the default to be en-US so that the tests for bind can work consistently. + options.SetDefaultCulture("en-US"); }); app.UseRouting();