Skip to content

Commit

Permalink
Adding passing test
Browse files Browse the repository at this point in the history
  • Loading branch information
ayende committed Dec 29, 2011
1 parent 2a9ec9d commit b8eddbd
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion Rhino.ServiceBus.Tests/Bugs/Serialization_roundtrip.cs
Expand Up @@ -51,6 +51,12 @@ public class ItemWithoutInitDictionary
public Dictionary<string, string> Arguments { get; set; }
}

public class ItemWithObjectDictionary
{
public string Name { get; set; }
public Dictionary<string, object> Arguments { get; set; }
}

[Fact]
public void Can_use_dictionaries_initialized()
{
Expand Down Expand Up @@ -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<string, object>
{
{"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()
{
Expand Down Expand Up @@ -156,4 +193,4 @@ public void Can_roundtrip_with_datetime_on_non_english_culture(string cultureNam
}
}
}
}
}

0 comments on commit b8eddbd

Please sign in to comment.