public void Passing_invalid_args_to_write_should_fail() { /* Arrange */ var handler = new CryptoConfigSectionHandler(); /* Act */ Action a1 = () => handler.WriteSection(null); Action a2 = () => handler.WriteSection(typeof(object)); /* Assert */ a1.ShouldThrow<ArgumentNullException>(); a2.ShouldThrow<ConfigException>().And.Errors.Should().ContainSingle(e => e.Code == ConfigErrorCode.InvalidConfigType); }
public void Handling_a_valid_crypto_provider_should_work() { /* Arrange */ var handler = new CryptoConfigSectionHandler(); /* Act */ var node = handler.WriteSection(typeof(AesCryptoProvider)); var nodeContents = node.Attribute(ConfigElement.SectionTypeAttribute).Value; var result = handler.ReadSection(node); /* Assert */ result.Should().BeOfType<AesCryptoProvider>(); nodeContents.Should().NotContain("AesCryptoProvider", "it must be encrypted"); }