public void Serialize_NonSerializableType_Exception() { using (var subject = new XmlRoundtripSerializer<NonSerializable>()) { Assert.That(() => subject.Serialize(new NonSerializable("s")), Throws.InstanceOf<InvalidOperationException>()); } }
public void Serialize_NonSerializableType_Exception() { using (var subject = new XmlRoundtripSerializer <NonSerializable>()) { Assert.That(() => subject.Serialize(new NonSerializable("s")), Throws.InstanceOf <InvalidOperationException>()); } }
public void Serialize_SerializableType_AStringRepresentationOfSerializedObject() { using (var subject = new XmlRoundtripSerializer<Serializable>()) { string representation = subject.Serialize(new Serializable { S = "s", D = 3m }); Assert.That(representation, Does.Contain("<S>s</S><D>3</D></Serializable>")); } }
public void XmlDeserialization_DoesNotPreserveInstanceUniqueness() { using (var serializer = new XmlRoundtripSerializer <CurrencyIsoCode>()) { CurrencyIsoCode usd = CurrencyIsoCode.USD; serializer.Serialize(usd); Assert.That(serializer.Deserialize(), Is.Not.SameAs(usd) .And.EqualTo(usd)); } }
public void XmlSerialization_OfObsoleteCurrency_Exception() { using (var serializer = new XmlRoundtripSerializer <CurrencyIsoCode>()) { #pragma warning disable 618 var obsolete = CurrencyIsoCode.EEK; #pragma warning restore 618 Assert.That(() => serializer.Serialize(obsolete), Throws.InstanceOf <InvalidOperationException>()); } }
public void XmlDeserialization_OfObsoleteCurrency_RaisesEvent(string threeLetterIsoCode) { using (var serializer = new XmlRoundtripSerializer <Currency>()) { var obsolete = Currency.Get(threeLetterIsoCode); serializer.Serialize(obsolete); Action deserializeObsolete = () => serializer.Deserialize(); Assert.That(deserializeObsolete, Must.Raise.ObsoleteEvent()); } }
public void Serialize_SerializableType_AStringRepresentationOfSerializedObject() { using (var subject = new XmlRoundtripSerializer <Serializable>()) { string representation = subject.Serialize(new Serializable { S = "s", D = 3m }); Assert.That(representation, Does.Contain("<S>s</S><D>3</D></Serializable>")); } }
public void XmlSerialization_OfDefaultInstance_StoresAndDeserializesNoCurrency() { var @default = new Money(); var serializer = new XmlRoundtripSerializer <Money>(); serializer.Serialize(@default); Money deserialized = serializer.Deserialize(); Assert.That(deserialized, Must.Be.MoneyWith(0m, Currency.Xxx)); }
public void Deserialize_AfterSerializingSerializableType_InitialObject() { using (var subject = new XmlRoundtripSerializer<Serializable>()) { var serialized = new Serializable { S = "s", D = 3m }; subject.Serialize(serialized); Serializable deserialized = subject.Deserialize(); Assert.That(deserialized, Is.Not.SameAs(serialized) .And.Property("S").EqualTo("s") .And.Property("D").EqualTo(3m)); } }
public void Deserialize_AfterSerializingSerializableType_InitialObject() { using (var subject = new XmlRoundtripSerializer <Serializable>()) { var serialized = new Serializable { S = "s", D = 3m }; subject.Serialize(serialized); Serializable deserialized = subject.Deserialize(); Assert.That(deserialized, Is.Not.SameAs(serialized) .And.Property("S").EqualTo("s") .And.Property("D").EqualTo(3m)); } }