Ejemplo n.º 1
0
        public void Should_provide_enumerators()
        {
            var config = LanguagesConfig.Create();

            Assert.Empty(config);

            Assert.NotNull(((IEnumerable)config).GetEnumerator());
            Assert.NotNull(((IEnumerable <IFieldPartitionItem>)config).GetEnumerator());
        }
Ejemplo n.º 2
0
        public void Should_add_language()
        {
            var config = LanguagesConfig.Create(Language.DE).Add(Language.IT);

            config.OfType <LanguageConfig>().ToList().ShouldBeEquivalentTo(
                new List <LanguageConfig>
            {
                new LanguageConfig(Language.DE),
                new LanguageConfig(Language.IT)
            });
        }
Ejemplo n.º 3
0
        public void Should_update_language()
        {
            var config = LanguagesConfig.Create(Language.DE).Add(Language.IT).Update(Language.IT, true, false, new[] { Language.DE });

            config.OfType <LanguageConfig>().ToList().ShouldBeEquivalentTo(
                new List <LanguageConfig>
            {
                new LanguageConfig(Language.DE),
                new LanguageConfig(Language.IT, true, Language.DE)
            });
        }
Ejemplo n.º 4
0
        public void Should_remove_language()
        {
            var config = LanguagesConfig.Create(Language.DE).Add(Language.IT).Add(Language.RU).Remove(Language.IT);

            config.ToList().ShouldBeEquivalentTo(
                new List <LanguageConfig>
            {
                new LanguageConfig(Language.DE),
                new LanguageConfig(Language.RU)
            });
        }
Ejemplo n.º 5
0
        public void Should_create_initial_config_with_configs()
        {
            var configs = new[]
            {
                new LanguageConfig(Language.DE),
                new LanguageConfig(Language.EN),
                new LanguageConfig(Language.IT)
            };
            var config = LanguagesConfig.Create(configs);

            config.OfType <LanguageConfig>().ToList().ShouldBeEquivalentTo(configs);

            Assert.Equal(configs[0], config.Master);
        }
Ejemplo n.º 6
0
        public void Should_create_initial_config()
        {
            var config = LanguagesConfig.Create(Language.DE);

            config.OfType <LanguageConfig>().ToList().ShouldBeEquivalentTo(
                new List <LanguageConfig>
            {
                new LanguageConfig(Language.DE)
            });

            Assert.Equal(Language.DE, config.Master.Language);

            Assert.Equal("de", ((IFieldPartitioning)config).Master.Key);
        }
Ejemplo n.º 7
0
        public void Should_create_initial_config_with_multiple_languages()
        {
            var config = LanguagesConfig.Create(Language.DE, Language.EN, Language.IT);

            config.OfType <LanguageConfig>().ToList().ShouldBeEquivalentTo(
                new List <LanguageConfig>
            {
                new LanguageConfig(Language.DE),
                new LanguageConfig(Language.EN),
                new LanguageConfig(Language.IT)
            });

            Assert.Equal(Language.DE, config.Master.Language);
        }
Ejemplo n.º 8
0
        public void Should_remove_fallbacks_when_removing_language()
        {
            var config =
                LanguagesConfig.Create(Language.DE)
                .Add(Language.IT)
                .Add(Language.RU)
                .Update(Language.DE, false, false, new[] { Language.RU, Language.IT })
                .Update(Language.RU, false, false, new[] { Language.DE, Language.IT })
                .Remove(Language.IT);

            config.OfType <LanguageConfig>().ToList().ShouldBeEquivalentTo(
                new List <LanguageConfig>
            {
                new LanguageConfig(Language.DE, false, Language.RU),
                new LanguageConfig(Language.RU, false, Language.DE)
            });
        }
Ejemplo n.º 9
0
        public async Task Should_not_add_error_if_required_field_has_no_value_for_optional_language()
        {
            var optionalConfig =
                LanguagesConfig.Create(Language.ES, Language.IT).Update(Language.IT, true, false, null);

            schema = schema.AddOrUpdateField(new StringField(1, "my-field", Partitioning.Language, new StringFieldProperties {
                IsRequired = true
            }));

            var data =
                new NamedContentData()
                .AddField("my-field",
                          new ContentFieldData()
                          .AddValue("es", "value"));

            await data.ValidateAsync(context, schema, optionalConfig.ToResolver(), errors);

            Assert.Empty(errors);
        }
Ejemplo n.º 10
0
        public void Should_throw_exception_if_fallback_language_is_invalid()
        {
            var config = LanguagesConfig.Create(Language.DE);

            Assert.Throws <ValidationException>(() => config.Update(Language.DE, false, false, new[] { Language.EN }));
        }
Ejemplo n.º 11
0
        public void Should_throw_exception_if_language_to_add_already_exists()
        {
            var config = LanguagesConfig.Create(Language.DE);

            Assert.Throws <ValidationException>(() => config.Add(Language.DE));
        }
Ejemplo n.º 12
0
        public void Should_make_master_language()
        {
            var config = LanguagesConfig.Create(Language.DE).Add(Language.IT).MakeMaster(Language.IT);

            Assert.Equal(Language.IT, config.Master.Language);
        }
Ejemplo n.º 13
0
        public void Should_throw_exception_if_language_to_remove_is_master_language()
        {
            var config = LanguagesConfig.Create(Language.DE);

            Assert.Throws <ValidationException>(() => config.Remove(Language.DE));
        }
Ejemplo n.º 14
0
        public void Should_throw_exception_if_language_to_remove_is_not_found()
        {
            var config = LanguagesConfig.Create(Language.DE);

            Assert.Throws <DomainObjectNotFoundException>(() => config.Remove(Language.EN));
        }
Ejemplo n.º 15
0
        public void Should_also_set_make_master_when_updating_language()
        {
            var config = LanguagesConfig.Create(Language.DE).Add(Language.IT).Update(Language.IT, false, true, null);

            Assert.Equal(Language.IT, config.Master.Language);
        }
Ejemplo n.º 16
0
        public void Should_throw_exception_if_language_to_make_optional_must_be_set_to_master()
        {
            var config = LanguagesConfig.Create(Language.DE).Add(Language.IT);

            Assert.Throws <ValidationException>(() => config.Update(Language.DE, true, true, null));
        }
Ejemplo n.º 17
0
        public void Should_throw_exception_if_language_to_make_optional_is_master_language()
        {
            var config = LanguagesConfig.Create(Language.DE);

            Assert.Throws <ValidationException>(() => config.Update(Language.DE, true, false, null));
        }
Ejemplo n.º 18
0
        public void Should_throw_exception_if_language_to_update_is_not_found()
        {
            var config = LanguagesConfig.Create(Language.DE);

            Assert.Throws <DomainObjectNotFoundException>(() => config.Update(Language.EN, true, false, null));
        }
Ejemplo n.º 19
0
        public void Should_not_throw_exception_if_language_is_already_master_language()
        {
            var config = LanguagesConfig.Create(Language.DE);

            config.MakeMaster(Language.DE);
        }