Exemple #1
0
 public void MainTest()
 {
     string[] args = { TestDataHelper.locateTestChunk1(), TestDataHelper.locateTestRestore() };
     CFSRestoreMain_Accessor.Main(args);
     //Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }
Exemple #2
0
        public void ReadFileTest2()
        {
            bool remember = Logger.UsuallyDebugging;

            Logger.UsuallyDebugging = true;
            Logger.setLogger(null);
            int    kperchunk = 640;
            string infn      = TestDataHelper.locateTestText();
            string mount     = "k:\\";
            string csize     = "640K";

            string[]       files = { mount, csize, infn };
            CFSDriveConfig cfg   = new CFSDriveConfig(null, mount, csize, files, 2);
            ChunkFSDriver  cfs   = new ChunkFSDriver(cfg);

            cfs.Init();
            Assert.IsTrue(cfs.Count() > 0);

            uint readBytes         = 64 * 1024;
            uint readBytesExpected = readBytes;

            byte[] buffer = new byte[readBytes];

            string   filename       = infn.Substring(infn.LastIndexOf("\\") + 1);
            FileInfo fi             = new FileInfo(infn);
            long     actualsize     = fi.Length;
            string   outDir         = fi.DirectoryName + "\\out\\";
            int      bytesperchunk  = kperchunk * 1024;
            int      chunksExpected = (int)((actualsize + (long)bytesperchunk - 1L) / (long)bytesperchunk);

            long            offset = 0;
            DokanFileInfo   info   = new DokanFileInfo(0);
            FileInformation finf   = new FileInformation();
            int             ok;

            for (int i = 0; i < chunksExpected; i++)
            {
                // get file info and note the size
                string uniq   = fi.LastWriteTime.ToString("yyyyMMddHHmm", CultureInfo.InvariantCulture);
                string currfn = filename + "." + uniq + "." + (i + 1) + "." + chunksExpected;
                ok = cfs.GetFileInformation(currfn, finf, info);
                long currcs = finf.Length;

                // open the file, create an output file
                ok = cfs.CreateFile(currfn, FileAccess.Read, FileShare.Read, FileMode.Open, FileOptions.None, info);
                FileStream ofs = new FileStream(outDir + currfn, FileMode.Create, FileAccess.Write);

                // read all the bytes and write to output
                offset = 0;
                do
                {
                    ok = cfs.ReadFile(currfn, buffer, ref readBytes, offset, info);
                    ofs.Write(buffer, 0, (int)readBytes);
                    offset += readBytes;
                } while (offset + 1 < currcs);

                // close the input and output
                ok = cfs.Cleanup(currfn, info);
                ok = cfs.CloseFile(currfn, info);
                string ofn = ofs.Name;
                ofs.Close();
                new FileInfo(ofn).LastWriteTime = finf.LastWriteTime;
            }
            // now you can compare the files TODO

            //int expected = 0;
            //int actual;
            //actual = cfs.ReadFile(filename, buffer, ref readBytes, offset, info);
            //Assert.AreEqual(readBytesExpected, readBytes);
            //Assert.AreEqual(expected, actual);
            //Assert.Inconclusive("Verify the correctness of this test method.");
            Logger.UsuallyDebugging = remember;
            Logger.setLogger(null);
        }