public void Deserialize_BeforeSerializing_Exception() { using (var subject = new DataContractRoundtripSerializer <Serializable>()) { Assert.That(() => subject.Deserialize(), Throws.InstanceOf <XmlException>()); } }
public void Deserialize_BeforeSerializing_Exception() { using (var subject = new DataContractRoundtripSerializer<Serializable>()) { Assert.That(() => subject.Deserialize(), Throws.InstanceOf<XmlException>()); } }
public void DataContractDeserialization_DoesNotPreserveInstanceUniqueness() { using (var serializer = new DataContractRoundtripSerializer <CurrencyIsoCode>()) { CurrencyIsoCode usd = CurrencyIsoCode.USD; serializer.Serialize(usd); Assert.That(serializer.Deserialize(), Is.Not.SameAs(usd) .And.EqualTo(usd)); } }
public void DataContractDeserialization_OfObsoleteCurrency_RaisesEvent(string threeLetterIsoCode) { using (var serializer = new DataContractRoundtripSerializer <Currency>()) { var obsolete = Currency.Get(threeLetterIsoCode); serializer.Serialize(obsolete); Action deserializeObsolete = () => serializer.Deserialize(); Assert.That(deserializeObsolete, Must.Raise.ObsoleteEvent()); } }
public void DataContractDeserialization_OfObsoleteCurrency_DoesNotRaiseEvent() { using (var serializer = new DataContractRoundtripSerializer <CurrencyIsoCode>()) { #pragma warning disable 618 var obsolete = CurrencyIsoCode.EEK; #pragma warning restore 618 serializer.Serialize(obsolete); Action deserializeObsolete = () => serializer.Deserialize(); Assert.That(deserializeObsolete, Must.Not.Raise.ObsoleteEvent()); } }
public void DatacontractSerialization_OfDefaultInstance_StoresAndDeserializesNoCurrency() { var @default = new Money(); var serializer = new DataContractRoundtripSerializer <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 DataContractRoundtripSerializer<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 DataContractRoundtripSerializer <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)); } }