Exemple #1
0
        public void EncryptSucceedsWithExistingICrypto()
        {
            ICrypto fooCrypto = CreateICrypto("foo");
            ICrypto barCrypto = CreateICrypto("bar");

            var compositeCrypto = new CompositeCrypto(new List <ICrypto> {
                fooCrypto, barCrypto
            });

            compositeCrypto.Encrypt("stuff", "foo").Should().Be("EncryptedString : foo");
            compositeCrypto.Encrypt(new byte[0], "foo").Should().BeEquivalentTo(Encoding.UTF8.GetBytes("foo"));
            compositeCrypto.Encrypt("stuff", "bar").Should().Be("EncryptedString : bar");
            compositeCrypto.Encrypt(new byte[0], "bar").Should().BeEquivalentTo(Encoding.UTF8.GetBytes("bar"));
        }
Exemple #2
0
        public void EncryptThrowsWhenICryptoDoesntExist()
        {
            ICrypto fooCrypto = CreateICrypto("foo");
            ICrypto barCrypto = CreateICrypto("bar");

            var compositeCrypto = new CompositeCrypto(new List <ICrypto> {
                fooCrypto, barCrypto
            });

            Action action = () => compositeCrypto.Encrypt("stuff", "baz");

            action.ShouldThrow <KeyNotFoundException>()
            .WithMessage("Unable to locate implementation of ICrypto that can locate a credential using credentialName: baz");
        }