public void CultureCodes_Given_Delimiter_IsEmptyString_Throws_Exception() { Should.Throw <Exception>(() => { LocalizationUtils.CultureCodes(""); }); }
public void CultureCodes_Given_Delimiter_IsHyphen_Throws_Exception(string hyphenatedDelimiter) { Should.Throw <Exception>(() => { LocalizationUtils.CultureCodes(hyphenatedDelimiter); }); }
public void CultureCodes_Given_Delimiter_IsNull_Throws_Exception() { Should.Throw <Exception>(() => { LocalizationUtils.CultureCodes(null); }); }
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); }
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); }