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

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

            var fooEncryptor = compositeCrypto.GetEncryptor("foo");
            var barEncryptor = compositeCrypto.GetEncryptor("bar");

            fooEncryptor.Should().NotBeNull();
            barEncryptor.Should().NotBeNull();
            fooEncryptor.Should().NotBeSameAs(barEncryptor);
        }
Exemple #2
0
        public void GetEncryptorThrowsWhenICryptoDoesntExist()
        {
            ICrypto fooCrypto = CreateICrypto("foo");
            ICrypto barCrypto = CreateICrypto("bar");

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

            Action action = () => compositeCrypto.GetEncryptor("baz");

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