private void TestWithSecretIntPtrActionSuccess(IProtectedMemoryAllocator protectedMemoryAllocator) { Debug.WriteLine("TestWithSecretIntPtrActionSuccess"); char[] secretChars = { 'a', 'b' }; using (ProtectedMemorySecret secret = ProtectedMemorySecret.FromCharArray(secretChars, protectedMemoryAllocator, configuration)) { secret.WithSecretIntPtr((ptr, len) => { Assert.NotEqual(ptr, IntPtr.Zero); Assert.True(len == 2); }); } }
private void TestWithSecretIntPtrDisposed(IProtectedMemoryAllocator protectedMemoryAllocator) { Debug.WriteLine("TestWithSecretIntPtrDisposed"); char[] secretChars = { 'a', 'b' }; ProtectedMemorySecret secret = ProtectedMemorySecret.FromCharArray(secretChars, protectedMemoryAllocator, configuration); secret.Dispose(); Assert.Throws <InvalidOperationException>(() => { secret.WithSecretIntPtr((ptr, len) => { return(true); }); }); }