public void TheObjectWriter()
        {
            var somethingToWrite =
                new SomethingToWrite
                    {
                        IntProperty = 42
                    };
            var somethingElseToWrite =
                new SomethingElseToWrite
                {
                    IntProperty = 42
                };

            somethingToWrite.SomethingSimple = somethingElseToWrite;
            somethingElseToWrite.SomethingSimple = somethingToWrite;

            var stream = new StringStream();
            var objectWriter = new ObjectWriter();

            objectWriter.Write(stream, somethingToWrite);
            var reader = stream.ToReader();
            Assert.Equal("#1 : SomethingToWrite.", reader.ReadLine());
            Assert.Equal("    IntProperty = 42 : Int32.", reader.ReadLine());
            Assert.Equal("    SomethingSimple = #2 : SomethingElseToWrite.", reader.ReadLine());
            Assert.Equal("        IntProperty = 42 : Int32.", reader.ReadLine());
            Assert.Equal("        SomethingSimple = #1 : SomethingToWrite.", reader.ReadLine());
            Assert.True(reader.EndOfStream);
        }
 public void TheObjectWriter()
 {
     var stream = new StringStream();
     var objectWriter = new ObjectWriter();
     objectWriter.Write(stream, new SomethingToWrite());
     var reader = stream.ToReader();
     Assert.Equal("#1 : SomethingToWrite.", reader.ReadLine());
     Assert.Equal("    IntListProperty : [Int32].", reader.ReadLine());
     Assert.True(reader.EndOfStream);
 }
Example #3
0
 public void TheObjectWriter()
 {
     var stream = new StringStream();
     var objectWriter = new ObjectWriter();
     objectWriter.Write(
         stream,
         new SomethingToWrite
             {
                 Property = Guid.Empty,
                 OtherProperty = null
             });
     var reader = stream.ToReader();
     Assert.Equal("#1 : SomethingToWrite.", reader.ReadLine());
     Assert.Equal("    Property = 00000000-0000-0000-0000-000000000000 : Guid.", reader.ReadLine());
     Assert.Equal("    OtherProperty = null : Guid.", reader.ReadLine()); ;
     Assert.True(reader.EndOfStream);
 }
Example #4
0
 public void TheObjectWriter()
 {
     var stream = new StringStream();
     var objectWriter = new ObjectWriter();
     objectWriter.Write(
         stream,
         new SomethingToWrite
         {
             IntProperty = 42,
             Int32Property = 42,
             NullableIntProperty = 42,
             NullableInt32Property = null
         });
     var reader = stream.ToReader();
     Assert.Equal("#1 : SomethingToWrite.", reader.ReadLine());
     Assert.Equal("    IntProperty = 42 : Int32.", reader.ReadLine());
     Assert.Equal("    Int32Property = 42 : Int32.", reader.ReadLine());
     Assert.Equal("    NullableIntProperty = 42 : Int32.", reader.ReadLine());
     Assert.Equal("    NullableInt32Property = null : Int32.", reader.ReadLine());
     Assert.True(reader.EndOfStream);
 }
Example #5
0
        public void TheIntWriter()
        {
            var writer = new IntWriter();
            var somethingToWrite =
                new SomethingToWrite
                    {
                        IntProperty = 42,
                        Int32Property = 42,
                        NullableIntProperty = 42,
                        NullableInt32Property = 42
                    };
            var stream = new StringStream();
            writer.Write(stream, somethingToWrite.IntProperty);
            Assert.Equal("42 : Int32.", stream.ToString());

            stream = new StringStream();
            writer.Write(stream, somethingToWrite.Int32Property);
            Assert.Equal("42 : Int32.", stream.ToString());

            stream = new StringStream();
            writer.Write(stream, somethingToWrite.NullableIntProperty);
            Assert.Equal("42 : Int32.", stream.ToString());

            stream = new StringStream();
            writer.Write(stream, somethingToWrite.NullableInt32Property);
            Assert.Equal("42 : Int32.", stream.ToString());

            stream = new StringStream();
            somethingToWrite.NullableIntProperty = null;
            writer.Write(stream, somethingToWrite.NullableIntProperty);
            Assert.Equal("null : Int32.", stream.ToString());

            stream = new StringStream();
            somethingToWrite.NullableInt32Property = null;
            writer.Write(stream, somethingToWrite.NullableInt32Property);
            Assert.Equal("null : Int32.", stream.ToString());
        }