|
|
@ -59,5 +59,26 @@ namespace Grpc.Core.Internal.Tests |
|
|
|
var nativeMetadata = MetadataArraySafeHandle.Create(metadata); |
|
|
|
var nativeMetadata = MetadataArraySafeHandle.Create(metadata); |
|
|
|
nativeMetadata.Dispose(); |
|
|
|
nativeMetadata.Dispose(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[Test] |
|
|
|
|
|
|
|
public void ReadMetadataFromPtrUnsafe() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var metadata = new Metadata |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
new Metadata.Entry("host", "somehost"), |
|
|
|
|
|
|
|
new Metadata.Entry("header2", "header value"), |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
var nativeMetadata = MetadataArraySafeHandle.Create(metadata); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var copy = MetadataArraySafeHandle.ReadMetadataFromPtrUnsafe(nativeMetadata.Handle); |
|
|
|
|
|
|
|
Assert.AreEqual(2, copy.Count); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.AreEqual("host", copy[0].Key); |
|
|
|
|
|
|
|
Assert.AreEqual("somehost", copy[0].Value); |
|
|
|
|
|
|
|
Assert.AreEqual("header2", copy[1].Key); |
|
|
|
|
|
|
|
Assert.AreEqual("header value", copy[1].Value); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nativeMetadata.Dispose(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|