public void Deserialize_BeforeSerializing_Exception()
 {
     using (var subject = new XmlRoundtripSerializer <Serializable>())
     {
         Assert.That(() => subject.Deserialize(), Throws.InstanceOf <InvalidOperationException>());
     }
 }
 public void Deserialize_BeforeSerializing_Exception()
 {
     using (var subject = new XmlRoundtripSerializer<Serializable>())
     {
         Assert.That(() => subject.Deserialize(), Throws.InstanceOf<InvalidOperationException>());
     }
 }
 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 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 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));
            }
        }