public DecideLanguageResult DecideLanguage() { if (_cache != null) { return(_cache); } string language = AppSettingsReader.DefaultLanguage; LanguageParameter languageParameter = LanguageParameterParser.ParseLanguageParameter(); if (languageParameter.IsPresent) { language = languageParameter.Language; } if (language.IsFilled() && !LanguageToCultureMapping.Mappings.ContainsKey(key: language)) { Console.WriteLine(text: $"Language \"{language}\" not supported."); language = DefaultFallbackLanguage; } language = language.IsFilled() ? language : DefaultFallbackLanguage; return(_cache = new DecideLanguageResult { Language = language }); }
public LanguageParameterParserTests() { _mockEnvironment = new Mock <IEnvironment>(); _mockConsole = new Mock <IConsole>(); ContainerBuilder containerBuilder = new ContainerBuilder(); containerBuilder .RegisterInstance(instance: _mockEnvironment.Object) .As <IEnvironment>(); containerBuilder .RegisterInstance(instance: _mockConsole.Object) .As <IConsole>(); containerBuilder .RegisterType <LanguageParameterParser>(); _systemUnderTest = containerBuilder .Build() .Resolve <LanguageParameterParser>(); }