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); }
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"); }