コード例 #1
0
 public void StringToAnsi_NullStringWorks()
 {
     //Act
     using (var target = SafeHGlobalHandle.StringToAnsi(null))
     {
         //Assert
         target.IsInvalid.Should().BeTrue();
         target.Pointer.Should().BeZero();
     };
 }
コード例 #2
0
        public void StringToAnsi_ValidStringWorks()
        {
            string str = "Hello";

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