Ejemplo n.º 1
0
        public void EncryptXmlThrowsWhenCryptoIsNull()
        {
            var xml           = "<foo bar=\"123\"><baz>456</baz><baz>789</baz><qux><garply grault=\"abc\" /></qux></foo>";
            var keyIdentifier = new object();

            ICrypto crypto = null;

            Assert.That(() => crypto.EncryptXml(xml, new[] { "/foo/@bar", "/foo/baz", "/foo/qux" }, keyIdentifier), Throws.ArgumentNullException);
        }
Ejemplo n.º 2
0
    public static void EncryptXmlThrowsWhenCryptoIsNull()
    {
        var xml = "<foo bar=\"123\"><baz>456</baz><baz>789</baz><qux><garply grault=\"abc\" /></qux></foo>";

        ICrypto crypto = null !;

        var act = () => crypto.EncryptXml(xml, new[] { "/foo/@bar", "/foo/baz", "/foo/qux" });

        act.Should().ThrowExactly <ArgumentNullException>();
    }
Ejemplo n.º 3
0
 /// <summary>
 /// Encrypts the fields, specified by XPath, that are contained in the given xml document string.
 /// </summary>
 /// <param name="crypto">
 /// The instance of <see cref="ICrypto"/> that ultimately responsible for performing encryption operations
 /// on field values.
 /// </param>
 /// <param name="xmlString">A string containing an xml document.</param>
 /// <param name="xpathToEncrypt">The XPath of the field to encrypt.</param>
 /// <param name="credentialName">
 /// The name of the credential to use for this encryption operation,
 /// or <c>null</c> to use the default credential.
 /// </param>
 /// <returns>The same xml document, except with the specified fields encrypted.</returns>
 public static string EncryptXml(this ICrypto crypto, string xmlString, string xpathToEncrypt, string?credentialName = null) =>
 crypto.EncryptXml(xmlString, new[] { xpathToEncrypt }, credentialName);