예제 #1
0
 public void CultureCodes_Given_Delimiter_IsEmptyString_Throws_Exception()
 {
     Should.Throw <Exception>(() =>
     {
         LocalizationUtils.CultureCodes("");
     });
 }
예제 #2
0
 public void CultureCodes_Given_Delimiter_IsHyphen_Throws_Exception(string hyphenatedDelimiter)
 {
     Should.Throw <Exception>(() =>
     {
         LocalizationUtils.CultureCodes(hyphenatedDelimiter);
     });
 }
예제 #3
0
 public void CultureCodes_Given_Delimiter_IsNull_Throws_Exception()
 {
     Should.Throw <Exception>(() =>
     {
         LocalizationUtils.CultureCodes(null);
     });
 }
예제 #4
0
        public void CultureCodes_Given_Custom_Delimiter_Returns_Custom_Delimited_Codes(string expectedDelimiter)
        {
            // Arrange
            var expectedCode = new CultureStub().Code;

            // Act
            var result = LocalizationUtils.CultureCodes(expectedDelimiter);

            // Assert
            result.ShouldNotBeNull();
            result.ShouldContain(expectedCode);
            result.ShouldContain(expectedDelimiter);
        }
예제 #5
0
        public void CultureCodes_Without_Arguments_Returns_Comma_Delimited_Codes()
        {
            // Arrange
            var expected = new CultureStub().Code;

            // Act
            var result = LocalizationUtils.CultureCodes();

            // Assert
            result.ShouldNotBeNull();
            result.ShouldContain(expected);
            result.ShouldContain(", ");
        }
        public static IServiceCollection AddAndcultureCodeLocalization(this IServiceCollection services)
        {
            var localizerFactory = new JsonStringLocalizerFactory();

            services.AddScoped <IStringLocalizer>((sp) => localizerFactory.Create(null));

            // Configuration of services
            services
            .ConfigureRequestLocalizationOptions()
            .ConfigureRewriteOptions()
            .ConfigureRouteOptions();

            Console.WriteLine($"Default Localization Culture: {LocalizationUtils.DefaultCultureCode}");
            Console.WriteLine($"Localization Cultures: {LocalizationUtils.CultureCodes(", ")}");

            return(services);
        }