public void TryGetSignatureProvider(CryptoProviderCacheTheoryData theoryData) { var context = TestUtilities.WriteHeader($"{this}.TryGetSignatureProvider", theoryData); try { var providerFound = theoryData.CryptoProviderCache.TryGetSignatureProvider(theoryData.SecurityKey, theoryData.Algorithm, theoryData.TypeofProvider, theoryData.WillCreateSignatures, out SignatureProvider signatureProvider); if (theoryData.Found != providerFound) { context.Diffs.Add($"theoryData.Found: '{theoryData.Found}' != theoryData.CryptoProviderCache.TryGetSignatureProvider: '{providerFound}'"); } } catch (Exception ex) { theoryData.ExpectedException.ProcessException(ex, context); } TestUtilities.AssertFailIfErrors(context); }
public void TryRemove(CryptoProviderCacheTheoryData theoryData) { var context = TestUtilities.WriteHeader($"{this}.TryRemove", theoryData); try { if (theoryData.Removed != theoryData.CryptoProviderCache.TryRemove(theoryData.SignatureProvider)) { context.Diffs.Add($"theoryData.Removed:'{theoryData.Removed}' != theoryData.CryptoProviderCache.TryRemove(theoryData.SignatureProvider)"); } theoryData.ExpectedException.ProcessNoException(context); } catch (Exception ex) { theoryData.ExpectedException.ProcessException(ex, context); } TestUtilities.AssertFailIfErrors(context); }
public void GetCacheKey(CryptoProviderCacheTheoryData theoryData) { var context = TestUtilities.WriteHeader($"{this}.GetCacheKey", theoryData); try { var keyFromComponents = theoryData.InMemoryCryptoProviderCachePublic.GetCacheKeyPublic(theoryData.SecurityKey, theoryData.Algorithm, theoryData.TypeofProvider); var keyFromProvider = theoryData.InMemoryCryptoProviderCachePublic.GetCacheKeyPublic(theoryData.SignatureProvider); if (keyFromProvider.Equals(keyFromComponents) != theoryData.ShouldCacheKeysMatch) { context.Diffs.Add($"theoryData.CacheKeysMatch:{Environment.NewLine}keyFromComponents: '{keyFromComponents}'{Environment.NewLine}!={Environment.NewLine}keyFromProvider: '{keyFromProvider}'."); } theoryData.ExpectedException.ProcessNoException(context); } catch (Exception ex) { theoryData.ExpectedException.ProcessException(ex, context); } TestUtilities.AssertFailIfErrors(context); }
public void TryAdd(CryptoProviderCacheTheoryData theoryData) { var context = TestUtilities.WriteHeader($"{this}.TryAdd", theoryData); try { bool shouldCreate = CryptoProviderFactory.ShouldCacheSignatureProvider(theoryData.SignatureProvider); var added = theoryData.CryptoProviderCache.TryAdd(theoryData.SignatureProvider); if (theoryData.Added != added && shouldCreate) { context.Diffs.Add($"theoryData.Added:'{theoryData.Added}' != theoryData.CryptoProviderCache.TryAdd(theoryData.SignatureProvider)"); } theoryData.ExpectedException.ProcessNoException(context); } catch (Exception ex) { theoryData.ExpectedException.ProcessException(ex, context); } TestUtilities.AssertFailIfErrors(context); }