Exemple #1
0
        public void LocalizeItem_HasCollectionOfLocalizableChildren_LocalizesCollection()
        {
            var localizedContent = GetLocalizedContent();

            var testClass = new TestClassA
            {
                ChildrenA = new[]
                {
                    new TestClassA
                    {
                        PropertyA = localizedContent
                    },
                    new TestClassA
                    {
                        PropertyA = localizedContent
                    }
                },
                ChildrenB = new[]
                {
                    new TestClassB
                    {
                        PropertyA = localizedContent
                    }
                }
            };

            var localized = testClass.Localize(DEFAULT_LANGUAGE, LocalizationDepth.Deep);

            Assert.Equal(ANY_STRING_1, localized.ChildrenA.ElementAt(0).PropertyA);
            Assert.Equal(ANY_STRING_1, localized.ChildrenA.ElementAt(1).PropertyA);
            Assert.Equal(ANY_STRING_1, localized.ChildrenB.ElementAt(0).PropertyA);
        }
Exemple #2
0
        public void LocalizeItem_NoPropertiesSpecified_LocalizesAllProperties()
        {
            var localizedContent = GetLocalizedContent();

            var testClass1 = new TestClassA
            {
                PropertyA = localizedContent,
                PropertyB = localizedContent
            };

            var testClass2 = new TestClassA
            {
                PropertyA = localizedContent,
                PropertyB = localizedContent
            };

            testClass1.Localize(DEFAULT_LANGUAGE);

            Assert.Equal(ANY_STRING_1, testClass1.PropertyA);
            Assert.Equal(ANY_STRING_1, testClass1.PropertyB);

            testClass2.Localize(OTHER_LANGUAGE);

            Assert.Equal(ANY_STRING_2, testClass2.PropertyA);
            Assert.Equal(ANY_STRING_2, testClass2.PropertyB);
        }
Exemple #3
0
        public void Set_ProvideLocalizedContentDictionary_SetsProperty()
        {
            var testClass = new TestClassA();

            var localizedContent = new Dictionary <string, string>
            {
                { DEFAULT_LANGUAGE, ANY_STRING_1 },
                { OTHER_LANGUAGE, ANY_STRING_2 }
            };

            testClass.Set(i => i.PropertyA, localizedContent);

            var localized = testClass.Localize(DEFAULT_LANGUAGE);

            Assert.Equal(ANY_STRING_1, localized.PropertyA);
        }
Exemple #4
0
        public void Set_ProvideLocalizedContentArray_SetsProperty()
        {
            var testClass = new TestClassA();

            var localizedContent = new[]
            {
                new LocalizedContent(DEFAULT_LANGUAGE, ANY_STRING_1),
                new LocalizedContent(OTHER_LANGUAGE, ANY_STRING_2)
            };

            testClass.Set(i => i.PropertyA, localizedContent);

            var localized = testClass.Localize(DEFAULT_LANGUAGE);

            Assert.Equal(ANY_STRING_1, localized.PropertyA);
        }
Exemple #5
0
        public void LocalizeItem_LocalizationDepthIsShallow_DoesNotLocalizeChildred()
        {
            var localizedContent = GetLocalizedContent();

            var testClass = new TestClassA
            {
                ChildA = new TestClassA
                {
                    PropertyA = localizedContent,
                    PropertyB = localizedContent
                }
            };

            var localized = testClass.Localize(DEFAULT_LANGUAGE);

            Assert.NotEqual(ANY_STRING_1, localized.ChildA.PropertyA);
            Assert.NotEqual(ANY_STRING_1, localized.ChildA.PropertyB);
        }
Exemple #6
0
        public void LocalizeItem_LocalizationDepthIsOneLevel_OnlyImmediateChildrenLocalized()
        {
            var localizedContent = GetLocalizedContent();

            var testClass = new TestClassA
            {
                ChildA = new TestClassA
                {
                    PropertyA = localizedContent,
                    ChildA    = new TestClassA
                    {
                        PropertyA = localizedContent
                    }
                }
            };

            var localized = testClass.Localize(DEFAULT_LANGUAGE, LocalizationDepth.OneLevel);

            Assert.Equal(ANY_STRING_1, localized.ChildA.PropertyA);
            Assert.NotEqual(ANY_STRING_1, localized.ChildA.ChildA.PropertyA);
        }
Exemple #7
0
        public void LocalizeItem_WithLocalizableChildren_LocalizesChildren()
        {
            var localizedContent = GetLocalizedContent();

            var testClass = new TestClassA
            {
                ChildA = new TestClassA
                {
                    PropertyA = localizedContent,
                    ChildA    = new TestClassA
                    {
                        PropertyA = localizedContent
                    }
                }
            };

            var localized = testClass.Localize(DEFAULT_LANGUAGE, LocalizationDepth.Deep);

            Assert.Equal(ANY_STRING_1, localized.ChildA.PropertyA);
            Assert.Equal(ANY_STRING_1, localized.ChildA.ChildA.PropertyA);
        }