Пример #1
0
        public void CanBuildModelDefinition_Property()
        {
            target.Property(x => x.IntProperty);
            var result = target.Build();

            Assert.True(result.ConfigurationProperties.ContainsKey(nameof(SimpleConfig.IntProperty)));
            Assert.Equal(nameof(SimpleConfig.IntProperty), result.ConfigurationProperties[nameof(SimpleConfig.IntProperty)].ConfigurationPropertyName);
            Assert.Equal("Int Property", result.ConfigurationProperties[nameof(SimpleConfig.IntProperty)].PropertyDisplayName);
        }
        public async Task FailsIfLessthanMin_int()
        {
            var min    = 3;
            var sample = new SampleConfig
            {
                LlamaCapacity = 2
            };

            modelBuilder.Property(k => k.LlamaCapacity).WithMinValue(min);
            var model  = modelBuilder.Build();
            var result = await target.Validate(sample, model, configIdentity);

            Assert.False(result.IsValid);
            Assert.Single(result.Errors);
            Assert.Equal(ValidationStrings.LessThanMin(nameof(SampleConfig.LlamaCapacity), min), result.Errors.Single());
        }
Пример #3
0
        public void FailsIfLessthanMin_int()
        {
            var min    = 3;
            var sample = new SampleConfig
            {
                LlamaCapacity = 2
            };

            modelBuilder.Property(k => k.LlamaCapacity).WithMinValue(min);
            var model  = modelBuilder.Build();
            var result = target.Validate(sample, model);

            Assert.False(result.IsValid);
            Assert.Equal(1, result.Errors.Count());
            Assert.Equal(string.Format(ValidationStrings.LessThanMin, nameof(SampleConfig.LlamaCapacity), min), result.Errors.Single());
        }