private void TestWithSecretUtf8CharsWithClosedSecretShouldFail() { char[] secretChars = { 'a', 'b' }; ProtectedMemorySecret secret = ProtectedMemorySecret.FromCharArray(secretChars, protectedMemoryAllocatorController); secret.Close(); Assert.Throws <InvalidOperationException>(() => { secret.WithSecretUtf8Chars(decryptedChars => true); }); }
private void TestWithSecretUtf8CharsWithClosedSecretShouldFail(IProtectedMemoryAllocator protectedMemoryAllocator) { Debug.WriteLine("TestWithSecretUtf8CharsWithClosedSecretShouldFail"); char[] secretChars = { 'a', 'b' }; ProtectedMemorySecret secret = ProtectedMemorySecret.FromCharArray(secretChars, protectedMemoryAllocator, configuration); secret.Close(); Assert.Throws <InvalidOperationException>(() => { secret.WithSecretUtf8Chars(decryptedChars => true); }); }
private void TestWithSecretUtf8CharsAction() { char[] secretChars = { 'a', 'b' }; using (ProtectedMemorySecret secret = ProtectedMemorySecret.FromCharArray(secretChars, protectedMemoryAllocatorController)) { secret.WithSecretUtf8Chars(decryptedChars => { Assert.Equal(secretChars, decryptedChars); }); } }
private void TestWithSecretUtf8CharsAction(IProtectedMemoryAllocator protectedMemoryAllocator) { Debug.WriteLine("TestWithSecretUtf8CharsAction"); char[] secretChars = { 'a', 'b' }; using (ProtectedMemorySecret secret = ProtectedMemorySecret.FromCharArray(secretChars, protectedMemoryAllocator, configuration)) { secret.WithSecretUtf8Chars(decryptedChars => { Assert.Equal(secretChars, decryptedChars); }); } }
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); }); }); }