예제 #1
0
 public void BufferedStreamCopyWithNullOutputStream()
 {
     using (MemoryStream ms = new MemoryStream())
     {
         Assert.That(() => StreamUtilities.BufferedStreamCopy(ms, null), Throws.ArgumentNullException);
     }
 }
 public void BufferedStreamCopyWithNullOutputStream()
 {
     using (MemoryStream ms = new MemoryStream())
     {
         StreamUtilities.BufferedStreamCopy(ms, null);
     }
 }
 public void BufferedStreamCopyWithNullInputStream()
 {
     using (MemoryStream ms = new MemoryStream())
     {
         StreamUtilities.BufferedStreamCopy(null, ms);
     }
 }
예제 #4
0
        public override void Add(Stream filetoAdd, string fileName, DateTime modificationTime)
        {
            ZipEntry entry = zip.PutNextEntry(fileName);

            entry.ModifiedTime = modificationTime;

            //You have to do this because if using a memory stream the pointer will be at the end it
            //it's just been read and this will cause nothing to be written out
            filetoAdd.Position = 0;

            StreamUtilities.BufferedStreamCopy(filetoAdd, zip);
            zip.Flush();
        }
예제 #5
0
        public void BufferedStreamCopyWithValidData()
        {
            const string streamContents = "This is a test";

            using (MemoryStream oms = new MemoryStream())
            {
                using (MemoryStream ims = new MemoryStream(Encoding.ASCII.GetBytes(streamContents)))
                {
                    StreamUtilities.BufferedStreamCopy(ims, oms);
                    Assert.AreEqual(ims, oms);
                }
            }
        }
예제 #6
0
 /// <summary>
 /// Read *from* this stream and write to the targetStream in a buffered manner as per the Read()
 /// </summary>
 /// <param name="targetStream">Stream to put data into</param>
 public void BufferedRead(Stream targetStream)
 {
     StreamUtilities.BufferedStreamCopy(this, targetStream);
 }
예제 #7
0
 /// <summary>
 /// Write *to* this stream *from* the source stream in a buffered manner analogous to Write()
 /// </summary>
 /// <param name="sourceStream">Stream get data from</param>
 public void BufferedWrite(Stream sourceStream)
 {
     StreamUtilities.BufferedStreamCopy(sourceStream, this);
 }
예제 #8
0
 public void BufferedStreamCopyWithNullOutputStream()
 {
     using (MemoryStream ms = new MemoryStream())
         Assert.Throws(typeof(ArgumentNullException), () => StreamUtilities.BufferedStreamCopy(ms, null));
 }