Beispiel #1
0
        public void CreateAndDeleteFile(IFileInfo fi)
        {
            FileStreamBase fs = fi.Create();

            fs.Close();
            fi.Delete();
        }
Beispiel #2
0
        private static void PipeFileContents(IFileInfo file, Stream pOut, int bufSize)
        {
            FileStreamBase inputStream = file.OpenRead();

            byte[] buf = new byte[bufSize];

            int len;

            while ((len = inputStream.Read(buf, 0, buf.Length)) > 0)
            {
                pOut.Write(buf, 0, len);
            }

            pOut.Dispose();
            inputStream.Dispose();
        }
Beispiel #3
0
        public void Check_that_FileInfo_methods_Create_and_Delete_are_called()
        {
            // Add mock repository.
            IFileInfo      fileInfoRepository   = Substitute.For <IFileInfo>();
            FileStreamBase fileStreamRepository = Substitute.For <FileStreamBase>();

            // Create expectations
            fileInfoRepository.Create().Returns(fileStreamRepository);


            // Test
            new FileInfoSample().CreateAndDeleteFile(fileInfoRepository);

            // Verify expectations.
            fileStreamRepository.Received().Close();
            fileInfoRepository.Received().Delete();
        }
Beispiel #4
0
 public virtual Stream GetInputStream()
 {
     return(FileStreamBase.Create(_file.FullName, FileMode.Open, FileAccess.Read, FileShare.Read, _bufSize));
 }