public void WhenConvertingToDataContractAndPassingExtraTypesThenInstanceIsReturned()
 {
     var customer = new CustomerWithItems() {CustomerID = 1};
     customer.Items = new List<object> {new ItemTypeA {Name = "An Item"}};
     var serializer = new DataContractSerializer(typeof (CustomerWithItems), new List<Type>{typeof(ItemTypeA)});
     var stream = new MemoryStream();
     serializer.WriteObject(stream, customer);
     stream.Position = 0;
     customer = (CustomerWithItems) serializer.ReadObject(stream);
     Assert.AreEqual("An Item", ((ItemTypeA)customer.Items[0]).Name);
 }
        public void WhenConvertingToDataContractAndPassingExtraTypesThenInstanceIsReturned()
        {
            var customer = new CustomerWithItems()
            {
                CustomerID = 1
            };

            customer.Items = new List <object> {
                new ItemTypeA {
                    Name = "An Item"
                }
            };
            var serializer = new DataContractSerializer(typeof(CustomerWithItems), new List <Type> {
                typeof(ItemTypeA)
            });
            var stream = new MemoryStream();

            serializer.WriteObject(stream, customer);
            stream.Position = 0;
            customer        = (CustomerWithItems)serializer.ReadObject(stream);
            Assert.AreEqual("An Item", ((ItemTypeA)customer.Items[0]).Name);
        }