copy() public method

public copy ( Stream @in ) : void
@in Stream
return void
コード例 #1
0
 public void testOneBlockAndHalf_Copy()
 {
     TemporaryBuffer b = new TemporaryBuffer();
     byte[] test = new TestRng(getName())
            .nextBytes(TemporaryBuffer.Block.SZ * 3 / 2);
     try
     {
         var @in = new MemoryStream(test);
         // [caytchen] StreamReader buffers data After the very first Read, thus advancing the Position in the underlying stream - causing this test to fail
         //var inReader = new StreamReader(@in);
         b.write(@in.ReadByte());
         b.copy(@in);
         b.close();
         Assert.AreEqual(test.Length, b.Length);
         {
             byte[] r = b.ToArray();
             Assert.IsNotNull(r);
             Assert.AreEqual(test.Length, r.Length);
             Assert.IsTrue(test.SequenceEqual(r));
         }
         {
             byte[] r;
             using (MemoryStream o = new MemoryStream())
             {
                 b.writeTo(o, null);
                 r = o.ToArray();
             }
             Assert.AreEqual(test.Length, r.Length);
             Assert.IsTrue(test.SequenceEqual(r));
         }
     }
     finally
     {
         b.destroy();
     }
 }
コード例 #2
0
ファイル: Patch.cs プロジェクト: stschake/GitSharp
 private static byte[] ReadFully(Stream stream)
 {
     var b = new TemporaryBuffer();
     try
     {
         b.copy(stream);
         b.close();
         return b.ToArray();
     }
     finally
     {
         b.destroy();
     }
 }
コード例 #3
0
 public void testInCoreLimit_SwitchOnCopy()
 {
     TemporaryBuffer b = new TemporaryBuffer();
     byte[] test = new TestRng(getName())
            .nextBytes(TemporaryBuffer.DEFAULT_IN_CORE_LIMIT * 2);
     try
     {
         MemoryStream @in = new MemoryStream(test,
                TemporaryBuffer.DEFAULT_IN_CORE_LIMIT, test.Length
                        - TemporaryBuffer.DEFAULT_IN_CORE_LIMIT);
         b.write(test, 0, TemporaryBuffer.DEFAULT_IN_CORE_LIMIT);
         b.copy(@in);
         b.close();
         Assert.AreEqual(test.Length, b.Length);
         {
             byte[] r = b.ToArray();
             Assert.IsNotNull(r);
             Assert.AreEqual(test.Length, r.Length);
             Assert.IsTrue(test.SequenceEqual(r));
         }
         {
             byte[] r;
             using (MemoryStream o = new MemoryStream())
             {
                 b.writeTo(o, null);
                 r = o.ToArray();
             }
             Assert.AreEqual(test.Length, r.Length);
             Assert.IsTrue(test.SequenceEqual(r));
         }
     }
     finally
     {
         b.destroy();
     }
 }