Ejemplo n.º 1
0
 public void SecureStringToAnsi_NullStringWorks()
 {
     //Act
     using (var target = SafeHGlobalHandle.SecureStringToAnsi(null))
     {
         //Assert
         target.IsInvalid.Should().BeTrue();
         target.Pointer.Should().BeZero();
     };
 }
Ejemplo n.º 2
0
        public void SecureStringToAnsi_ZeroesMemoryWhenClosed()
        {
            var str    = CreateSecureString("Hello");
            var target = SafeHGlobalHandle.SecureStringToAnsi(str);

            //Act
            target.Close();

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

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