Example #1
0
        public void Should_build_edm_model()
        {
            var languagesConfig = LanguagesConfig.Create(Language.DE, Language.EN);

            var edmModel = BuildMixedSchema().BuildEdmType(languagesConfig.ToResolver(), x => x);

            Assert.NotNull(edmModel);
        }
Example #2
0
        public void Should_build_schema()
        {
            var languagesConfig = LanguagesConfig.Create(Language.DE, Language.EN);

            var jsonSchema = BuildMixedSchema().BuildJsonSchema(languagesConfig.ToResolver(), (n, s) => new JsonSchema4 {
                SchemaReference = s
            });

            Assert.NotNull(jsonSchema);
        }
Example #3
0
        private LanguagesConfig CreateLanguagesConfig()
        {
            languagesConfig = LanguagesConfig.Create(Languages?.Select(ToLanguageConfig).ToList() ?? new List <LanguageConfig>());

            if (MasterLanguage != null)
            {
                languagesConfig = languagesConfig.MakeMaster(MasterLanguage);
            }

            return(languagesConfig);
        }
Example #4
0
        public void Should_return_flat_list_when_single_languages_specified()
        {
            var data =
                new NamedContentData()
                .AddField("field1",
                          new ContentFieldData()
                          .AddValue("de", 1)
                          .AddValue("en", 2))
                .AddField("field2",
                          new ContentFieldData()
                          .AddValue("de", null)
                          .AddValue("en", 4))
                .AddField("field3",
                          new ContentFieldData()
                          .AddValue("en", 6))
                .AddField("field4",
                          new ContentFieldData()
                          .AddValue("it", 7));

            var fallbackConfig =
                LanguagesConfig.Create(Language.DE).Add(Language.EN)
                .Update(Language.DE, false, false, new[] { Language.EN });

            var output = (Dictionary <string, JToken>)data.ToLanguageModel(fallbackConfig, new List <Language> {
                Language.DE
            });

            var expected = new Dictionary <string, JToken>
            {
                { "field1", 1 },
                { "field2", 4 },
                { "field3", 6 }
            };

            Assert.True(expected.EqualsDictionary(output));
        }