make intializer for metadata even nicer

pull/2866/head
Jan Tattermusch 9 years ago
parent 5321d49b51
commit 410c473c2b
  1. 4
      src/csharp/Grpc.Core.Tests/ClientServerTest.cs
  2. 2
      src/csharp/Grpc.Core.Tests/CompressionTest.cs
  3. 8
      src/csharp/Grpc.Core.Tests/Internal/MetadataArraySafeHandleTest.cs
  4. 5
      src/csharp/Grpc.Core.Tests/ResponseHeadersTest.cs
  5. 10
      src/csharp/Grpc.Core/Metadata.cs

@ -190,8 +190,8 @@ namespace Grpc.Core.Tests
var headers = new Metadata
{
new Metadata.Entry("ascii-header", "abcdefg"),
new Metadata.Entry("binary-header-bin", new byte[] { 1, 2, 3, 0, 0xff }),
{ "ascii-header", "abcdefg" },
{ "binary-header-bin", new byte[] { 1, 2, 3, 0, 0xff } }
};
var call = Calls.AsyncUnaryCall(helper.CreateUnaryCall(new CallOptions(headers: headers)), "ABC");
await call;

@ -94,7 +94,7 @@ namespace Grpc.Core.Tests
context.WriteOptions = new WriteOptions(WriteFlags.NoCompress);
await context.WriteResponseHeadersAsync(new Metadata { new Metadata.Entry("ascii-header", "abcdefg") });
await context.WriteResponseHeadersAsync(new Metadata { { "ascii-header", "abcdefg" } });
await responseStream.WriteAsync("X");

@ -53,8 +53,8 @@ namespace Grpc.Core.Internal.Tests
{
var metadata = new Metadata
{
new Metadata.Entry("host", "somehost"),
new Metadata.Entry("header2", "header value"),
{ "host", "somehost" },
{ "header2", "header value" },
};
var nativeMetadata = MetadataArraySafeHandle.Create(metadata);
nativeMetadata.Dispose();
@ -65,8 +65,8 @@ namespace Grpc.Core.Internal.Tests
{
var metadata = new Metadata
{
new Metadata.Entry("host", "somehost"),
new Metadata.Entry("header2", "header value"),
{ "host", "somehost" },
{ "header2", "header value" }
};
var nativeMetadata = MetadataArraySafeHandle.Create(metadata);

@ -63,10 +63,7 @@ namespace Grpc.Core.Tests
server.Start();
channel = helper.GetChannel();
headers = new Metadata
{
new Metadata.Entry("ascii-header", "abcdefg"),
};
headers = new Metadata { { "ascii-header", "abcdefg" } };
}
[TearDown]

@ -114,6 +114,16 @@ namespace Grpc.Core
entries.Add(item);
}
public void Add(string key, string value)
{
Add(new Entry(key, value));
}
public void Add(string key, byte[] valueBytes)
{
Add(new Entry(key, valueBytes));
}
public void Clear()
{
CheckWriteable();

Loading…
Cancel
Save