diff options
author | Jon Skeet <skeet@pobox.com> | 2016-05-06 06:29:03 +0100 |
---|---|---|
committer | Jon Skeet <skeet@pobox.com> | 2016-05-06 06:29:03 +0100 |
commit | 5b5e369b185325c49ee450965ceceb6ac5586b16 (patch) | |
tree | 5dac86476f4d2cafa84333d3c1114a9632c71395 /csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs | |
parent | 17b6fc31eb8a9b65501cd7c53235a88efdc94394 (diff) | |
parent | 61307b86f561721ac47ecd74d9fd1dffa0acad53 (diff) | |
download | protobuf-5b5e369b185325c49ee450965ceceb6ac5586b16.tar.gz protobuf-5b5e369b185325c49ee450965ceceb6ac5586b16.tar.bz2 protobuf-5b5e369b185325c49ee450965ceceb6ac5586b16.zip |
Merge pull request #1471 from jskeet/any-host
Allow custom type URL prefixes in Any.Pack
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs')
-rw-r--r-- | csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs b/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs index f3593e5f..f21be7d9 100644 --- a/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs +++ b/csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs @@ -47,6 +47,24 @@ namespace Google.Protobuf.WellKnownTypes } [Test] + public void Pack_WithCustomPrefix() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var any = Any.Pack(message, "foo.bar/baz"); + Assert.AreEqual("foo.bar/baz/protobuf_unittest.TestAllTypes", any.TypeUrl); + Assert.AreEqual(message.CalculateSize(), any.Value.Length); + } + + [Test] + public void Pack_WithCustomPrefixTrailingSlash() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var any = Any.Pack(message, "foo.bar/baz/"); + Assert.AreEqual("foo.bar/baz/protobuf_unittest.TestAllTypes", any.TypeUrl); + Assert.AreEqual(message.CalculateSize(), any.Value.Length); + } + + [Test] public void Unpack_WrongType() { var message = SampleMessages.CreateFullTestAllTypes(); @@ -64,6 +82,15 @@ namespace Google.Protobuf.WellKnownTypes } [Test] + public void Unpack_CustomPrefix_Success() + { + var message = SampleMessages.CreateFullTestAllTypes(); + var any = Any.Pack(message, "foo.bar/baz"); + var unpacked = any.Unpack<TestAllTypes>(); + Assert.AreEqual(message, unpacked); + } + + [Test] public void ToString_WithValues() { var message = SampleMessages.CreateFullTestAllTypes(); |