public void CantWriteWrongType()
        {
            var toWrite          = "Hello";
            var reflectionWriter = new ReflectionTypeWriter(typeof(SimpleObjectClass));

            Assert.Throws <ArgumentException>(() => reflectionWriter.WriteType(toWrite, this.mockedWriter.Object));
        }
        public void CanWriteHardSerializeableCtor()
        {
            var toWrite          = new HasHardSerializableCtor(1, 2, 3);
            var reflectionWriter = new ReflectionTypeWriter(toWrite.GetType());

            reflectionWriter.WriteType(toWrite, this.mockedWriter.Object);

            this.mockedWriter.Verify(mw => mw.Write(It.IsAny <object>()), Times.Exactly(3));
        }
        public void IgnoredAutoPropertiesAreNotDeserialized()
        {
            var toWrite          = new HasIgnoredAutoProperty(123);
            var reflectionWriter = new ReflectionTypeWriter(toWrite.GetType());

            reflectionWriter.WriteType(toWrite, this.mockedWriter.Object);

            this.mockedWriter.Verify(mr => mr.Write(It.IsAny <Type>()), Times.Never());
        }
        public void AutoPropertiesAreDeserialized()
        {
            var toWrite          = new HasAutoProperty();
            var reflectionWriter = new ReflectionTypeWriter(toWrite.GetType());

            reflectionWriter.WriteType(toWrite, this.mockedWriter.Object);

            this.mockedWriter.Verify(mr => mr.Write(It.IsAny <object>()), Times.Once());
        }
        public void NonAutoPropertiesAreNotDeSerialized()
        {
            var toWrite          = new HasPropertyWithBackingField();
            var reflectionWriter = new ReflectionTypeWriter(toWrite.GetType());

            reflectionWriter.WriteType(toWrite, this.mockedWriter.Object);

            this.mockedWriter.Verify(mr => mr.Write(It.IsAny <object>()), Times.Once());
        }
        public void IgnoresFieldThatUseIgnoreSerializeAttribute()
        {
            var toWrite          = new HasIgnoredField();
            var reflectionWriter = new ReflectionTypeWriter(toWrite.GetType());

            reflectionWriter.WriteType(toWrite, this.mockedWriter.Object);

            this.mockedWriter.Verify(mr => mr.Write(It.IsAny <object>()), Times.Once());
        }