OLD | NEW |
1 #region Copyright notice and license | 1 #region Copyright notice and license |
2 // Protocol Buffers - Google's data interchange format | 2 // Protocol Buffers - Google's data interchange format |
3 // Copyright 2015 Google Inc. All rights reserved. | 3 // Copyright 2015 Google Inc. All rights reserved. |
4 // https://developers.google.com/protocol-buffers/ | 4 // https://developers.google.com/protocol-buffers/ |
5 // | 5 // |
6 // Redistribution and use in source and binary forms, with or without | 6 // Redistribution and use in source and binary forms, with or without |
7 // modification, are permitted provided that the following conditions are | 7 // modification, are permitted provided that the following conditions are |
8 // met: | 8 // met: |
9 // | 9 // |
10 // * Redistributions of source code must retain the above copyright | 10 // * Redistributions of source code must retain the above copyright |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 var unpacked = any.Unpack<TestAllTypes>(); | 89 var unpacked = any.Unpack<TestAllTypes>(); |
90 Assert.AreEqual(message, unpacked); | 90 Assert.AreEqual(message, unpacked); |
91 } | 91 } |
92 | 92 |
93 [Test] | 93 [Test] |
94 public void ToString_WithValues() | 94 public void ToString_WithValues() |
95 { | 95 { |
96 var message = SampleMessages.CreateFullTestAllTypes(); | 96 var message = SampleMessages.CreateFullTestAllTypes(); |
97 var any = Any.Pack(message); | 97 var any = Any.Pack(message); |
98 var text = any.ToString(); | 98 var text = any.ToString(); |
99 Assert.That(text, Does.Contain("\"@value\": \"" + message.ToByteStri
ng().ToBase64() + "\"")); | 99 Assert.That(text, Is.StringContaining("\"@value\": \"" + message.ToB
yteString().ToBase64() + "\"")); |
100 } | 100 } |
101 | 101 |
102 [Test] | 102 [Test] |
103 public void ToString_Empty() | 103 public void ToString_Empty() |
104 { | 104 { |
105 var any = new Any(); | 105 var any = new Any(); |
106 Assert.AreEqual("{ \"@type\": \"\", \"@value\": \"\" }", any.ToStrin
g()); | 106 Assert.AreEqual("{ \"@type\": \"\", \"@value\": \"\" }", any.ToStrin
g()); |
107 } | 107 } |
108 | 108 |
109 [Test] | 109 [Test] |
110 public void ToString_MessageContainingAny() | 110 public void ToString_MessageContainingAny() |
111 { | 111 { |
112 var message = new TestWellKnownTypes { AnyField = new Any() }; | 112 var message = new TestWellKnownTypes { AnyField = new Any() }; |
113 Assert.AreEqual("{ \"anyField\": { \"@type\": \"\", \"@value\": \"\"
} }", message.ToString()); | 113 Assert.AreEqual("{ \"anyField\": { \"@type\": \"\", \"@value\": \"\"
} }", message.ToString()); |
114 } | 114 } |
115 } | 115 } |
116 } | 116 } |
OLD | NEW |