Beispiel #1
0
 public void TestApiBufferConverting()
 {
     AGDnsApi.ag_buffer apiBuffer = new AGDnsApi.ag_buffer();
     try
     {
         string basicString = "krasivyeshpilinasolberiiskomsobore";
         byte[] basicBuffer = Encoding.UTF8.GetBytes(basicString);
         apiBuffer = MarshalUtils.BytesToAgBuffer(basicBuffer);
         Assert.AreNotEqual(apiBuffer.data, IntPtr.Zero);
         Assert.AreNotEqual(apiBuffer.size, 0);
         byte[] convertedBuffer = MarshalUtils.AgBufferToBytes(apiBuffer);
         Assert.AreNotEqual(convertedBuffer.Length, 0);
         string convertedString = Encoding.UTF8.GetString(convertedBuffer);
         Assert.AreEqual(basicString, convertedString);
     }
     finally
     {
         MarshalUtils.SafeFreeHGlobal(apiBuffer.data);
     }
 }