public void Test()
        {
            var c = new SerializerTestCollection();

            Assert.AreEqual(0, c.Serializers.Count);
            var f = new TestSerializationFactory(c);

            Assert.AreEqual(1, c.Serializers.Count);
            Assert.IsInstanceOfType(c.Serializers[0], typeof(TestCollectionSerializer));

            var i = new SerializerTestItem();

            Assert.AreEqual(0, i.Serializers.Count);
            c.Add(i);
            Assert.AreEqual(1, i.Serializers.Count);
            Assert.IsInstanceOfType(i.Serializers[0], typeof(TestItemSerializer));
            TestItemSerializer s = (TestItemSerializer)i.Serializers[0];

            c.Remove(i);
            Assert.IsTrue(s.IsDisposed);
            Assert.AreEqual(0, i.Serializers.Count);

            i = new SerializerTestItem();
            c.Add(i);
            Assert.AreEqual(1, i.Serializers.Count);
            Assert.IsInstanceOfType(i.Serializers[0], typeof(TestItemSerializer));
            s = (TestItemSerializer)i.Serializers[0];

            f.Dispose();
            Assert.IsTrue(s.IsDisposed);
        }
        public void SerializeOnPropertyChangedTest()
        {
            var collection = new SerializerTestCollection();

            collection.PropertyChanged   += Collection_PropertyChanged;
            collection.CollectionChanged += Collection_CollectionChanged;

            var serializer = new TestCollectionSerializer(collection);

            collection.Serializers.Add(serializer);

            //Test on Add
            serializer.SerializerCalled       = false;
            serializer.DeserializerCalled     = false;
            _notifyCollectionChangedEventArgs = null;
            _propertyChangedEventArgs         = null;

            serializer.SerializerCalled       = false;
            serializer.DeserializerCalled     = false;
            _notifyCollectionChangedEventArgs = null;
            _propertyChangedEventArgs         = null;

            var item = new SerializerTestItem {
                Prop = 1
            };

            collection.Add(item);

            Assert.IsTrue(serializer.SerializerCalled);
            Assert.IsFalse(serializer.DeserializerCalled);
            Assert.IsNotNull(_notifyCollectionChangedEventArgs);
            Assert.IsNull(_propertyChangedEventArgs);


            //Collection Property change test
            serializer.SerializerCalled       = false;
            serializer.DeserializerCalled     = false;
            _notifyCollectionChangedEventArgs = null;
            _propertyChangedEventArgs         = null;

            collection.Prop++;

            Assert.IsTrue(serializer.SerializerCalled);
            Assert.IsFalse(serializer.DeserializerCalled);
            Assert.IsNull(_notifyCollectionChangedEventArgs);
            Assert.IsNotNull(_propertyChangedEventArgs);


            //Item Property change test - must not be serialized
            serializer.DefaultCheckPropertyChanged = true;
            serializer.SerializerCalled            = false;
            serializer.DeserializerCalled          = false;
            _notifyCollectionChangedEventArgs      = null;
            _propertyChangedEventArgs = null;

            item.Prop++;

            Assert.IsFalse(serializer.SerializerCalled);
            Assert.IsFalse(serializer.DeserializerCalled);
            Assert.IsNull(_notifyCollectionChangedEventArgs);
            Assert.IsNotNull(_propertyChangedEventArgs);

            serializer.DefaultCheckPropertyChanged = false;
            serializer.SerializerCalled            = false;
            serializer.DeserializerCalled          = false;
            _notifyCollectionChangedEventArgs      = null;
            _propertyChangedEventArgs = null;

            item.Prop++;

            Assert.IsTrue(serializer.SerializerCalled);
            Assert.IsFalse(serializer.DeserializerCalled);
            Assert.IsNull(_notifyCollectionChangedEventArgs);
            Assert.IsNotNull(_propertyChangedEventArgs);
        }