diff options
author | csharptest <roger@csharptest.net> | 2011-06-10 18:01:34 -0500 |
---|---|---|
committer | rogerk <devnull@localhost> | 2011-06-10 18:01:34 -0500 |
commit | 4dc0dfb1546998b15a5e98d5dde6154d463365f2 (patch) | |
tree | 2dc8961df1e5c67e215c5e119a2989ba04a58511 /src/ProtocolBuffers.Test/CompatTests/DictionaryCompatibilityTests.cs | |
parent | ddb74eb6a45e758f6690f237fdf60b98d76e02fb (diff) | |
download | protobuf-4dc0dfb1546998b15a5e98d5dde6154d463365f2.tar.gz protobuf-4dc0dfb1546998b15a5e98d5dde6154d463365f2.tar.bz2 protobuf-4dc0dfb1546998b15a5e98d5dde6154d463365f2.zip |
Added initial DictionaryReader/Writer implementations
Diffstat (limited to 'src/ProtocolBuffers.Test/CompatTests/DictionaryCompatibilityTests.cs')
-rw-r--r-- | src/ProtocolBuffers.Test/CompatTests/DictionaryCompatibilityTests.cs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/ProtocolBuffers.Test/CompatTests/DictionaryCompatibilityTests.cs b/src/ProtocolBuffers.Test/CompatTests/DictionaryCompatibilityTests.cs new file mode 100644 index 00000000..8de82ea9 --- /dev/null +++ b/src/ProtocolBuffers.Test/CompatTests/DictionaryCompatibilityTests.cs @@ -0,0 +1,37 @@ +using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text;
+using Google.ProtocolBuffers.Serialization;
+using NUnit.Framework;
+
+namespace Google.ProtocolBuffers.CompatTests
+{
+ [TestFixture]
+ public class DictionaryCompatibilityTests : CompatibilityTests
+ {
+ protected override object SerializeMessage<TMessage, TBuilder>(TMessage message)
+ {
+ DictionaryWriter writer = new DictionaryWriter();
+ writer.WriteMessage(message);
+ return writer.ToDictionary();
+ }
+
+ protected override TBuilder DeerializeMessage<TMessage, TBuilder>(object message, TBuilder builder, ExtensionRegistry registry)
+ {
+ new DictionaryReader((IDictionary<string, object>)message).Merge(builder);
+ return builder;
+ }
+
+ protected override void AssertOutputEquals(object lhs, object rhs)
+ {
+ IDictionary<string, object> left = (IDictionary<string, object>)lhs;
+ IDictionary<string, object> right = (IDictionary<string, object>)rhs;
+
+ Assert.AreEqual(
+ String.Join(",", new List<string>(left.Keys).ToArray()),
+ String.Join(",", new List<string>(right.Keys).ToArray())
+ );
+ }
+ }
+}
\ No newline at end of file |