ToReader() public method

public ToReader ( ) : StreamReader
return System.IO.StreamReader
        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);
        }
示例#2
0
 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);
 }
示例#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);
 }
示例#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);
 }