Ejemplo n.º 1
0
            public void ShouldThrowConfigurationValidationException_WhenConfigurationIsInvalid()
            {
                // Arrange
                var configuration = GetInMemoryConfigurationObject(new Dictionary <string, string>
                {
                    { "TestProperty1", "Hi" },
                    { "TestProperty3", "0" }
                });

                // Act
                Func <TestConfiguration> result = () => ConfigurationExtensions.GetValidated <TestConfiguration>(configuration);

                // Act And Assert
                result.Should().Throw <ConfigurationValidationException>()
                .WithMessage("Configuration section TestConfiguration has an invalid setting");
            }
Ejemplo n.º 2
0
            public void ShouldReturnConfigurationObject_WhenConfigurationIsValid()
            {
                // Arrange
                var expectedConfig = new TestConfiguration
                {
                    TestProperty1 = "Hello",
                    TestProperty2 = "Goodbye",
                    TestProperty3 = 0,
                };

                var configuration = GetInMemoryConfigurationObject(new Dictionary <string, string>
                {
                    { "TestProperty1", "Hello" },
                    { "TestProperty2", "Goodbye" },
                    { "TestProperty3", "0" }
                });

                // Act
                var result = ConfigurationExtensions.GetValidated <TestConfiguration>(configuration);

                // Assert
                result.Should().BeEquivalentTo(expectedConfig);
            }
Ejemplo n.º 3
0
 public void ShouldThrowArgumentNullException_WhenConfigurationIsNull()
 {
     Assert.Throws <ArgumentNullException>(() => ConfigurationExtensions.GetValidated <int>(null));
 }