コード例 #1
0
        public void RemoveThenAdd()
        {
            TranslatedString.DefaultLanguage = Language.English;
            ITranslatedString str = Create(
                new KeyValuePair <Language, string>(Language.English, EnglishString),
                new KeyValuePair <Language, string>(Language.French, FrenchString));

            str.RemoveNonDefault(Language.French);
            str.Set(Language.French, "Hmm");
            Assert.True(str.TryLookup(Language.French, out var outStr));
            Assert.Equal("Hmm", outStr);
        }
コード例 #2
0
        public void RemoveDirect()
        {
            TranslatedString.DefaultLanguage = Language.English;
            ITranslatedString str = Create(EnglishString);

            str.RemoveNonDefault(Language.French);

            // English string
            Assert.Equal(EnglishString, str.String);
            Assert.True(str.TryLookup(Language.English, out var outStr));
            Assert.Equal(EnglishString, outStr);
            Assert.Equal(EnglishString, str.Lookup(Language.English));
        }
コード例 #3
0
        public void Remove()
        {
            TranslatedString.DefaultLanguage = Language.English;
            ITranslatedString str = Create(
                new KeyValuePair <Language, string>(Language.English, EnglishString),
                new KeyValuePair <Language, string>(Language.French, FrenchString));

            str.RemoveNonDefault(Language.French);

            // English string
            Assert.Equal(EnglishString, str.String);
            Assert.True(str.TryLookup(Language.English, out var outStr));
            Assert.Equal(EnglishString, outStr);
            Assert.Equal(EnglishString, str.Lookup(Language.English));

            // French string
            Assert.False(str.TryLookup(Language.French, out _));
            Assert.Null(str.Lookup(Language.French));
        }