public void Should_resolve_languages_and_resolve_master_language_from_invariant()
        {
            var source =
                new ContentFieldData()
                .AddValue("iv", "A")
                .AddValue("it", "B");

            var expected =
                new ContentFieldData()
                .AddValue("en", "A");

            var result = FieldConverters.ResolveLanguages(languagesConfig)(source, stringLanguageField);

            Assert.Equal(expected, result);
        }
        public void Should_resolve_languages_and_cleanup_old_languages()
        {
            var source =
                new ContentFieldData()
                .AddValue("en", "EN")
                .AddValue("it", "IT");

            var expected =
                new ContentFieldData()
                .AddValue("en", "EN");

            var result = FieldConverters.ResolveLanguages(languagesConfig)(source, stringLanguageField);

            Assert.Equal(expected, result);
        }
示例#3
0
        private IEnumerable <FieldConverter> GenerateConverters(Context context, ValueConverter?cleanReferences)
        {
            if (!context.IsFrontendClient)
            {
                yield return(excludedHiddenField);

                yield return(excludedHiddenValue);
            }

            yield return(excludedChangedField);

            yield return(excludedChangedValue);

            if (cleanReferences != null)
            {
                yield return(FieldConverters.ForValues(cleanReferences));
            }

            yield return(FieldConverters.ResolveInvariant(context.App.Languages));

            yield return(FieldConverters.ResolveLanguages(context.App.Languages));

            if (!context.IsFrontendClient)
            {
                if (context.ShouldResolveLanguages())
                {
                    yield return(FieldConverters.ResolveFallbackLanguages(context.App.Languages));
                }

                var languages = context.Languages();

                if (languages.Any())
                {
                    yield return(FieldConverters.FilterLanguages(context.App.Languages, languages));
                }

                var assetUrls = context.AssetUrls().ToList();

                if (assetUrls.Count > 0)
                {
                    var appId = context.App.NamedId();

                    var resolveAssetUrls = ValueConverters.ResolveAssetUrls(appId, assetUrls, urlGenerator);

                    yield return(FieldConverters.ForValues(resolveAssetUrls));
                }
            }
        }
        public void Should_resolve_languages_and_cleanup_old_languages()
        {
            var field = Fields.String(1, "string", Partitioning.Language);

            var source =
                new ContentFieldData()
                .AddLocalized("en", "EN")
                .AddLocalized("it", "IT");

            var expected =
                new ContentFieldData()
                .AddLocalized("en", "EN");

            var result = FieldConverters.ResolveLanguages(languagesConfig)(source, field);

            Assert.Equal(expected, result);
        }
示例#5
0
        private IEnumerable <FieldConverter> GenerateConverters(Context context, ValueConverter?cleanReferences)
        {
            if (!context.IsFrontendClient)
            {
                yield return(FieldConverters.ExcludeHidden());

                yield return(FieldConverters.ForNestedName2Name(ValueConverters.ExcludeHidden()));
            }

            yield return(FieldConverters.ExcludeChangedTypes());

            yield return(FieldConverters.ForNestedName2Name(ValueConverters.ExcludeChangedTypes()));

            if (cleanReferences != null)
            {
                yield return(FieldConverters.ForValues(cleanReferences));

                yield return(FieldConverters.ForNestedName2Name(cleanReferences));
            }

            yield return(FieldConverters.ResolveInvariant(context.App.LanguagesConfig));

            yield return(FieldConverters.ResolveLanguages(context.App.LanguagesConfig));

            if (!context.IsFrontendClient)
            {
                if (context.ShouldResolveLanguages())
                {
                    yield return(FieldConverters.ResolveFallbackLanguages(context.App.LanguagesConfig));
                }

                var languages = context.Languages();

                if (languages.Any())
                {
                    yield return(FieldConverters.FilterLanguages(context.App.LanguagesConfig, languages));
                }

                var assetUrls = context.AssetUrls();

                if (assetUrls.Any())
                {
                    yield return(FieldConverters.ResolveAssetUrls(assetUrls.ToList(), assetUrlGenerator));
                }
            }
        }
示例#6
0
        public void Should_resolve_languages_and_resolve_master_language_from_invariant()
        {
            var field = Fields.String(1, "string", Partitioning.Language);

            var source =
                new ContentFieldData()
                .AddLocalized("iv", "A")
                .AddLocalized("it", "B");

            var expected =
                new ContentFieldData()
                .AddLocalized("en", "A");

            var result = FieldConverters.ResolveLanguages(languagesConfig)(source, field);

            Assert.Equal(expected, result);
        }