public async void GetDefaultCultureInfoIfCultureKeysAreMissingOrInvalid()
 {
     using (var server = TestServer.Create(app =>
     {
         var options = new RequestLocalizationOptions()
         {
             SupportedCultures = new List<CultureInfo>
             {
                 new CultureInfo("ar-SA")
             },
             SupportedUICultures = new List<CultureInfo>
             {
                 new CultureInfo("ar-SA")
             }
         };
         var provider = new CookieRequestCultureProvider();
         provider.CookieName = "Preferences";
         options.RequestCultureProviders.Insert(0, provider);
         app.UseRequestLocalization(options, defaultRequestCulture: new RequestCulture("en-US"));
         app.Run(context =>
         {
             var requestCultureFeature = context.Features.Get<IRequestCultureFeature>();
             var requestCulture = requestCultureFeature.RequestCulture;
             Assert.Equal("en-US", requestCulture.Culture.Name);
             return Task.FromResult(0);
         });
     }))
     {
         var client = server.CreateClient();
         client.DefaultRequestHeaders.Add("Cookie", new CookieHeaderValue("Preferences", "uic=ar-SA").ToString());
         var response = await client.GetAsync(string.Empty);
     }
 }
 public async void GetCultureInfoFromPersistentCookie()
 {
     using (var server = TestServer.Create(app =>
     {
         var options = new RequestLocalizationOptions();
         var provider = new CookieRequestCultureProvider();
         provider.CookieName = "Preferences";
         options.RequestCultureProviders.Insert(0, provider);
         app.UseRequestLocalization(options);
         app.Run(context =>
         {
             var requestCultureFeature = context.Features.Get<IRequestCultureFeature>();
             var requestCulture = requestCultureFeature.RequestCulture;
             Assert.Equal("ar-SA", requestCulture.Culture.Name);
             return Task.FromResult(0);
         });
     }))
     {
         var client = server.CreateClient();
         var culture = new CultureInfo("ar-SA");
         var requestCulture = new RequestCulture(culture);
         var value = CookieRequestCultureProvider.MakeCookieValue(requestCulture);
         client.DefaultRequestHeaders.Add("Cookie", new CookieHeaderValue("Preferences", value).ToString());
         var response = await client.GetAsync(string.Empty);
         Assert.Equal("c=ar-SA|uic=ar-SA", value);
     }
 }
 public async void GetDefaultCultureInfoIfCookieDoesNotExist()
 {
     using (var server = TestServer.Create(app =>
     {
         var options = new RequestLocalizationOptions();
         var provider = new CookieRequestCultureProvider();
         provider.CookieName = "Preferences";
         options.RequestCultureProviders.Insert(0, provider);
         app.UseRequestLocalization(options);
         app.Run(context =>
         {
             var requestCultureFeature = context.Features.Get<IRequestCultureFeature>();
             var requestCulture = requestCultureFeature.RequestCulture;
             Assert.Equal(options.DefaultRequestCulture.Culture.Name, requestCulture.Culture.Name);
             return Task.FromResult(0);
         });
     }))
     {
         var client = server.CreateClient();
         var response = await client.GetAsync(string.Empty);
     }
 }
        public async void GetDefaultCultureInfoIfCookieDoesNotExist()
        {
            var builder = new WebApplicationBuilder()
                .Configure(app =>
                {
                    var options = new RequestLocalizationOptions
                    {
                        DefaultRequestCulture = new RequestCulture("en-US"),
                        SupportedCultures = new List<CultureInfo>
                        {
                            new CultureInfo("ar-SA")
                        },
                        SupportedUICultures = new List<CultureInfo>
                        {
                            new CultureInfo("ar-SA")
                        }
                    };
                    var provider = new CookieRequestCultureProvider();
                    provider.CookieName = "Preferences";
                    options.RequestCultureProviders.Insert(0, provider);
                    app.UseRequestLocalization(options);
                    app.Run(context =>
                    {
                        var requestCultureFeature = context.Features.Get<IRequestCultureFeature>();
                        var requestCulture = requestCultureFeature.RequestCulture;
                        Assert.Equal("en-US", requestCulture.Culture.Name);
                        return Task.FromResult(0);
                    });
                });

            using (var server = new TestServer(builder))
            {
                var client = server.CreateClient();
                var response = await client.GetAsync(string.Empty);
            }
        }