public void Can_deserialize_complex_object_graph() { var serializer = new XmlMessageSerializer(); var stream = new MemoryStream(); serializer.Serialize(new[] { sample }, stream); stream.Position = 0; var order = serializer.Deserialize(stream).As<Order>(); sample.Url.ShouldEqual(order.Url); sample.At.ShouldEqual(order.At); sample.Count.ShouldEqual(order.Count); sample.OrderId.ShouldEqual(order.OrderId); sample.TimeToDelivery.ShouldEqual(order.TimeToDelivery); order.OrderLines.ShouldHaveCount(2); sample.OrderLines[0].Product.ShouldEqual(order.OrderLines[0].Product); sample.OrderLines[1].Product.ShouldEqual(order.OrderLines[1].Product); }
public void can_round_trip_object_array() { var messages = new object[] {sample, sample2, new Address {City = "SLC", State = "Utah"}}; var serializer = new XmlMessageSerializer(); var stream = new MemoryStream(); serializer.Serialize(messages, stream); stream.Position = 0; var actual = serializer.Deserialize(stream).ShouldBeOfType<object[]>(); actual[0].ShouldBeOfType<Order>(); actual[1].ShouldBeOfType<Order>(); actual[2].ShouldBeOfType<Address>(); }
public void can_serialize_and_deserialize_when_dictionary_property_null() { var serializer = new XmlMessageSerializer(); var stream = new MemoryStream(); serializer.Serialize(new object[] { new ClassWithDictionary { DictionaryItems = null } }, stream); stream.Position = 0; var actual = serializer.Deserialize(stream).As<ClassWithDictionary>(); actual.DictionaryItems.ShouldBeNull(); }
public void Can_serialize_and_deserialize_float() { float aFloat = 1.12f; var serializer = new XmlMessageSerializer(); var stream = new MemoryStream(); serializer.Serialize(new object[] { aFloat }, stream); stream.Position = 0; var actual = (float)serializer.Deserialize(stream).As<float>(); aFloat.ShouldEqual(actual); }
public void Can_serialize_and_deserialize_primitive() { long ticks = DateTime.Now.Ticks; var serializer = new XmlMessageSerializer(); var stream = new MemoryStream(); serializer.Serialize(new object[] { ticks }, stream); stream.Position = 0; var actual = (long)serializer.Deserialize(stream).As<long>(); ticks.ShouldEqual(actual); }
public void can_serialize_and_deserialize_dictionary() { var serializer = new XmlMessageSerializer(); var stream = new MemoryStream(); serializer.Serialize(new object[] { new ClassWithDictionary { DictionaryItems = new Dictionary<string, object[]> { {"products", new object[] {new OrderLine {Product = "ayende"}}} } } }, stream); stream.Position = 0; var actual = serializer.Deserialize(stream).As<ClassWithDictionary>(); "ayende".ShouldEqual(actual.DictionaryItems["products"][0].As<OrderLine>().Product); }
public void Can_serialize_and_deserialize_double() { double aDouble = 1.12; var serializer = new XmlMessageSerializer(); var stream = new MemoryStream(); serializer.Serialize(new object[] { aDouble }, stream); stream.Position = 0; var actual = (double)serializer.Deserialize(stream).As<double>(); aDouble.ShouldEqual(actual); }
public void Can_serialize_and_deserialize_DateTimeOffset() { var value = DateTimeOffset.Now; var serializer = new XmlMessageSerializer(); var stream = new MemoryStream(); serializer.Serialize(new object[] { value }, stream); stream.Position = 0; var actual = (DateTimeOffset)serializer.Deserialize(stream).As<DateTimeOffset>(); value.ShouldEqual(actual); }
public void Can_serialize_and_deserialize_byte_array() { var serializer = new XmlMessageSerializer(); var stream = new MemoryStream(); serializer.Serialize(new object[] { new byte[] { 1, 2, 3, 4 } }, stream); stream.Position = 0; var actual = (byte[])serializer.Deserialize(stream).As<byte[]>(); new byte[] { 1, 2, 3, 4 }.ShouldEqual(actual); }
public void Can_serialize_and_deserialize_array() { var serializer = new XmlMessageSerializer(); var stream = new MemoryStream(); serializer.Serialize(new object[] { new ClassWithObjectArray { Items = new object[] {new OrderLine {Product = "ayende"}} } }, stream); stream.Position = 0; var actual = serializer.Deserialize(stream).As<ClassWithObjectArray>(); "ayende".ShouldEqual(actual.Items[0].As<OrderLine>().Product); }
public void can_round_trip_single_message() { var serializer = new XmlMessageSerializer(); var stream = new MemoryStream(); serializer.Serialize(sample, stream); stream.Position = 0; var actual = serializer.Deserialize(stream).ShouldBeOfType<Order>(); actual.OrderId.ShouldEqual(sample.OrderId); }
public XmlMessageSerializerRhinoMessageTester() { _serializer = new XmlMessageSerializer(); _stream = new MemoryStream(); }