I am feeling good today and I invite you to read below and smile along with me.
[su_note note_color=”#fafafa”]All tests pass as written on Sitecore 7.1 Update 1. Isolation provided by Sitecore.FakeDb[/su_note]
The Stage
1 | public class LanguageQuirksTest |
3 | private const string LanguageWithNoName = @"" ; |
5 | private class SmartDataProvider : DataProvider |
There Is A Language With No Name
2 | public void ThereIsALanguageWithNoName() |
4 | LanguageManager.IsValidLanguageName(LanguageWithNoName) |
6 | .BeTrue( "Of course there's a language with no name" ); |
A Language With No Name Has No Name
2 | public void ALanguageWithNoNameHasNoName() |
4 | var language = Language.Parse(LanguageWithNoName); |
6 | language.Should().NotBeNull( "Sitecore knows there's a language with no name" ); |
8 | language.Name.Should().BeEmpty( "A language with no name has no name. Of course!" ); |
Is There Really A Language With No Name?
2 | public void LanguageSwitcherDoesNotAgreeWithLanguageManager() |
4 | Action create = () => new LanguageSwitcher(LanguageWithNoName); |
6 | create.ShouldThrow<InvalidOperationException>( "Nope, there isn't. Sorry buddy." ); |
I Default To English
2 | public void GlobalsDefaultsToUs() |
6 | Globals.DefaultCulture.Name.Should().Be( "en-US" , "We are in US" ); |
7 | Globals.DefaultCulture.TwoLetterISOLanguageName.Should().Be( "en" , "And of course we speak English" ); |
11 | public void SettingsDefaultsToEn() |
13 | Settings.DefaultLanguage.Should().Be( "en" , "English is the world language" ); |
14 | Settings.ClientLanguage.Should().Be( "en" , "Did I tell you that English is the world language?" ); |
I Default To English and American English
2 | public void DataProviderKnowsOfTwoLanguages() |
4 | var provider = new SmartDataProvider(); |
5 | var context = new CallContext( new DataManager(Database.GetDatabase( "master" )), 0); |
7 | LanguageCollection languages = provider.GetLanguages(context); |
9 | languages.Should().HaveCount(2); |
11 | languages.Should().Contain(Language.Parse( "en" ), "English is the world language" ); |
12 | languages.Should().Contain(Language.Parse( "en-US" ), "Wait... and so is American English!" ); |
14 | languages.Should().NotContain(Language.Parse(LanguageWithNoName), "... sorry buddy" ); |
🙂