From b8eddbdc57be3e47d5cf133209db90037baff7a8 Mon Sep 17 00:00:00 2001 From: Ayende Rahien Date: Thu, 29 Dec 2011 12:39:23 +0200 Subject: [PATCH] Adding passing test --- .../Bugs/Serialization_roundtrip.cs | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/Rhino.ServiceBus.Tests/Bugs/Serialization_roundtrip.cs b/Rhino.ServiceBus.Tests/Bugs/Serialization_roundtrip.cs index 9a0bb8f..ec0928f 100644 --- a/Rhino.ServiceBus.Tests/Bugs/Serialization_roundtrip.cs +++ b/Rhino.ServiceBus.Tests/Bugs/Serialization_roundtrip.cs @@ -51,6 +51,12 @@ public class ItemWithoutInitDictionary public Dictionary Arguments { get; set; } } + public class ItemWithObjectDictionary + { + public string Name { get; set; } + public Dictionary Arguments { get; set; } + } + [Fact] public void Can_use_dictionaries_initialized() { @@ -92,6 +98,37 @@ public void Can_use_dictionaries_uninitialized() Assert.Equal("cdef", foo.Arguments["abc"]); } + public class Dog + { + public string Name { get; set; } + } + + [Fact] + public void Can_handle_dictionaries_where_values_are_objects() + { + var serializer = new XmlMessageSerializer(new DefaultReflection(), + new CastleServiceLocator(new WindsorContainer())); + + var stream = new MemoryStream(); + serializer.Serialize(new object[] { new ItemWithObjectDictionary() { Name = "abc", Arguments = new Dictionary + { + {"abc","cdef"}, + {"def", 1}, + {"123", new Dog{Name = "Oscar"}} + }} }, stream); + + stream.Position = 0; + + stream.Position = 0; + + + var foo = (ItemWithObjectDictionary)serializer.Deserialize(stream)[0]; + Assert.Equal("abc", foo.Name); + Assert.Equal("cdef", foo.Arguments["abc"]); + Assert.Equal(1, (int)foo.Arguments["def"]); + Assert.Equal("Oscar", ((Dog)foo.Arguments["123"]).Name); + } + [Fact] public void Can_roundtrip() { @@ -156,4 +193,4 @@ public void Can_roundtrip_with_datetime_on_non_english_culture(string cultureNam } } } -} \ No newline at end of file +}