public void options_are_invalid_if_they_contain_null_string()
        {
            var serviceCollection = new ServiceCollection();
            var configuration     = SimpleOptions.GetConfiguration(null);

            serviceCollection.RegisterOptionsByConvention <SimpleOptions>(configuration);

            var result = serviceCollection.ValidateIOptionsValues();

            result.Should().Be(false);
        }
        public void Options_are_valid_if_they_dont_contain_empty_string_or_number_zero()
        {
            var serviceCollection = new ServiceCollection();
            var configuration     = SimpleOptions.GetConfiguration("test", 100);

            serviceCollection.RegisterOptionsByConvention <SimpleOptions>(configuration);

            var result = serviceCollection.ValidateIOptionsValues();

            result.Should().Be(true);
        }
        public void diagnostics_for_valid_options_are_empty()
        {
            var serviceCollection = new ServiceCollection();
            var configuration     = SimpleOptions.GetConfiguration("validValue", 1);

            serviceCollection.RegisterOptionsByConvention <SimpleOptions>(configuration);

            var result = serviceCollection.ValidateIOptionsValues(out var diagnostics);

            result.Should().Be(true);
            diagnostics.Should().BeEmpty();
        }
        public void diagnostics_for_invalid_options_contains_name_of_misconfigured_option()
        {
            var serviceCollection = new ServiceCollection();
            var configuration     = SimpleOptions.GetConfiguration(null, 0);

            serviceCollection.RegisterOptionsByConvention <SimpleOptions>(configuration);

            var result = serviceCollection.ValidateIOptionsValues(out var diagnostics);

            result.Should().Be(false);
            diagnostics.Should().Contain(nameof(SimpleOptions));
            diagnostics.Should().Contain(nameof(SimpleOptions.StringOption));
            diagnostics.Should().Contain(nameof(SimpleOptions.IntOption));
        }