Example #1
0
        public void Serialization()
        {
            HostDisposedException originalEx = new HostDisposedException("someObject", new ObjectDisposedException("someObject"));
            HostDisposedException deserializedEx;

            BinaryFormatter bf = new BinaryFormatter();

            using (MemoryStream ms = new MemoryStream())
            {
                bf.Serialize(ms, originalEx);
                ms.Seek(0, 0);
                deserializedEx = (HostDisposedException)bf.Deserialize(ms);
            }

            Assert.Equal(originalEx.ToString(), deserializedEx.ToString());
        }
Example #2
0
        public void Serialization()
        {
            HostDisposedException originalEx = new HostDisposedException("someObject", new ObjectDisposedException("someObject"));
            HostDisposedException deserializedEx;

            BinaryFormatter bf = new BinaryFormatter();

            using (MemoryStream ms = new MemoryStream())
            {
#pragma warning disable SYSLIB0011 // Type or member is obsolete
                bf.Serialize(ms, originalEx);
                ms.Seek(0, 0);
                deserializedEx = (HostDisposedException)bf.Deserialize(ms);
#pragma warning restore SYSLIB0011 // Type or member is obsolete
            }

            Assert.Equal(originalEx.ToString(), deserializedEx.ToString());
        }