public async Task FailsIfOptionNotAvailable()
        {
            var sample = new SampleConfig
            {
                OptionFromConfigSet = new OptionFromConfigSet {
                    Id = 5, Description = "Option Four"
                }
            };

            modelBuilder.PropertyWithOption(p => p.OptionFromConfigSet, (SampleConfigSet provider) => provider.Options);
            var model  = modelBuilder.Build();
            var result = await target.Validate(sample, model, configIdentity);

            Assert.False(result.IsValid);
            Assert.Single(result.Errors);
            Assert.Equal(ValidationStrings.OptionNotFound(nameof(SampleConfig.OptionFromConfigSet)), result.Errors.Single());
        }
Пример #2
0
        public async Task FailsIfOneOptionNotAvailable()
        {
            var sample = new SampleConfig
            {
                MoarOptions = new List <Option>
                {
                    new Option {
                        Id = 5, Description = "Option Four"
                    },
                    OptionProvider.OptionOne
                }
            };

            modelBuilder.PropertyWithMultipleOptions(p => p.MoarOptions, (SampleConfigSet provider) => provider.Options);
            var model  = modelBuilder.Build();
            var result = await target.Validate(sample, model, configIdentity);

            Assert.False(result.IsValid);
            Assert.Equal(1, result.Errors.Count());
            Assert.Equal(ValidationStrings.OptionNotFound(nameof(SampleConfig.MoarOptions)), result.Errors.Single());
        }