예제 #1
0
 public void SecureStringToUnicode_NullStringWorks()
 {
     //Act
     using (var target = SafeComMemoryHandle.SecureStringToUnicode(null))
     {
         //Assert
         target.IsInvalid.Should().BeTrue();
         target.Pointer.Should().BeZero();
     };
 }
예제 #2
0
        public void SecureStringToUnicode_ZeroesMemoryWhenClosed()
        {
            var str    = CreateSecureString("Hello");
            var target = SafeComMemoryHandle.SecureStringToUnicode(str);

            //Act
            target.Close();

            //Assert - All we can do is verify it doesn't blow up
            target.IsClosed.Should().BeTrue();
        }
예제 #3
0
        public void SecureStringToUnicode_ValidStringWorks()
        {
            var str = CreateSecureString("Hello");

            //Act
            using (var target = SafeComMemoryHandle.SecureStringToUnicode(str))
            {
                //Assert
                target.IsInvalid.Should().BeFalse();
                AssertMemory(target.Pointer, Encoding.Unicode.GetBytes("Hello"));
            };
        }