public void RoundtripHappyPath()
        {
            var dummy     = new SerializableDummy();
            var roundtrip = BinaryFormatterAssert.Roundtrip(dummy);

            FieldAssert.Equal(dummy, roundtrip);
        }
示例#2
0
        /// <summary>
        /// Calls:
        /// - BinaryFormatterAssert.Roundtrip(item)
        /// - XmlSerializerAssert.Roundtrip(item)
        /// - DataContractSerializerAssert.Roundtrip(item)
        /// </summary>
        /// <returns>The roundtripped results.</returns>
        public static RoundtripResults <T> RoundtripAll <T>(T item)
        {
            var binary        = BinaryFormatterAssert.Roundtrip(item);
            var xmlSerializer = XmlSerializerAssert.Roundtrip(item);
            var dataContract  = DataContractSerializerAssert.Roundtrip(item);

            return(new RoundtripResults <T>(binary, xmlSerializer, dataContract));
        }
        public void RoundtripMissingSerializable()
        {
            var dummy    = new Dummy();
            var ex       = Assert.Throws <AssertException>(() => BinaryFormatterAssert.Roundtrip(dummy));
            var expected = "  Writing Dummy to a stream failed.\r\n" +
                           "  SerializationException: Type 'Gu.SerializationAsserts.Tests.Dtos.Dummy' in Assembly 'Gu.SerializationAsserts.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.";

            Assert.AreEqual(expected, ex.Message);
        }