private void TestCreateSecretByteArray() { Debug.WriteLine("\nTestCreateSecretByteArray: Start"); using Secret secret = transientSecretFactory.CreateSecret(new byte[] { 0, 1 }); Assert.Equal(typeof(SecureMemorySecret), secret.GetType()); Debug.WriteLine("TestCreateSecretByteArray: Finish\n"); }
private void MultiThreadedWithSecretBytesAccess() { ISecretFactory secretFactory = new TransientSecretFactory(null); Secret secret = secretFactory.CreateSecret(payload.Clone() as byte[]); // Get the current settings and try to force minWorkers ThreadPool.GetMinThreads(out _, out var currentMinIOC); Assert.True(ThreadPool.SetMinThreads(NumThreads, currentMinIOC)); int completedTasks = 0; Parallel.ForEach(Enumerable.Range(0, NumThreads), i => { try { secret.WithSecretBytes(decryptedBytes => { Assert.Equal(payload, decryptedBytes); Interlocked.Increment(ref completedTasks); }); } catch (ThreadInterruptedException e) { Logger.LogError(e, "Unexpected error during call"); throw; } }); Assert.Equal(NumThreads, completedTasks); }
private void TestCreateSecretByteArray() { Secret secret = transientSecretFactory.CreateSecret(new byte[] { 0, 1 }); Assert.Equal(typeof(ProtectedMemorySecret), secret.GetType()); }