public void GetDecryptorSucceedsWithExistingICrypto() { ICrypto fooCrypto = CreateICrypto("foo"); ICrypto barCrypto = CreateICrypto("bar"); var compositeCrypto = new CompositeCrypto(new List <ICrypto> { fooCrypto, barCrypto }); var fooEncryptor = compositeCrypto.GetDecryptor("foo"); var barEncryptor = compositeCrypto.GetDecryptor("bar"); fooEncryptor.Should().NotBeNull(); barEncryptor.Should().NotBeNull(); fooEncryptor.Should().NotBeSameAs(barEncryptor); }
public void GetDecryptorThrowsWhenICryptoDoesntExist() { ICrypto fooCrypto = CreateICrypto("foo"); ICrypto barCrypto = CreateICrypto("bar"); var compositeCrypto = new CompositeCrypto(new List <ICrypto> { fooCrypto, barCrypto }); Action action = () => compositeCrypto.GetDecryptor("baz"); action.ShouldThrow <KeyNotFoundException>() .WithMessage("Unable to locate implementation of ICrypto that can locate a credential using credentialName: baz"); }