QBackupTests/Tests.cs
/// <summary>
/// Integration test that tests that analysis tools actually generate a correct representation of source directory,
/// it archives it correctly and is then able to extract it back without corrupting or losing any files.
/// </summary>
Integration test that tests that analysis tools actually generate a correct representation of source directory,
it archives it correctly and is then able to extract it back without corrupting or losing any files.
Integration test that tests that analysis tools actually generate a correct representation of source directory it archives it correctly and is then able to extract it back without corrupting or losing any files .
[Test]
        public static void TestAnalysis()
        {
            var log = new LogLines();
            var t = new TestDir(InputDir);
            t.Create();
            var src = AnalyzedBackup.Create(t.Dirs[0], true, log);
            Assert.AreEqual(t.Dirs.Count, src.Dirs.Count);
            Assert.AreEqual(t.Files.Count, src.Files.Count);
            var dirs_by_path = src.Dirs.ToDictionary(x => x.AbsolutePath);
            foreach (var exp_dir in t.Dirs)
            {
                CompareDir(exp_dir, dirs_by_path[exp_dir], t);
            }
            var files_by_path = src.Files.ToDictionary(x => x.GetAbsolutePath());
            foreach (var exp_file in t.Files)
            {
                Assert.AreEqual(exp_file, files_by_path[exp_file].GetAbsolutePath());
                var fi = new FileInfo(exp_file);
                QAssert.AreEqual(fi.Length, files_by_path[exp_file].Size);
                QAssert.AreEqual(fi.LastWriteTime, files_by_path[exp_file].LastWriteTime);
            }
            var archived_dir = src.Compress(OutputDir, Password, 256, log);
            var archived = ArchivedBackup.CreateFromPath(archived_dir, Password, log);
            QAssert.AreEqual(src, archived);
            var extracted_dir = archived.Extract(ExtractedDir, Password, log);
            var extracted = AnalyzedBackup.Create(extracted_dir, true, log);
            QAssert.AreEqual(src, extracted);
            Directory.Delete(src.Root.Path, true);
            Directory.Delete(archived_dir.Path, true);
            Directory.Delete(extracted_dir.Path, true);
        }
[ Test ] public static void TestAnalysis ( ) { var log = new LogLines ( ) ; var t = new TestDir ( InputDir ) ; t . Create ( ) ; var src = AnalyzedBackup . Create ( t . Dirs [ 0 ] , true , log ) ; Assert . AreEqual ( t . Dirs . Count , src . Dirs . Count ) ; Assert . AreEqual ( t . Files . Count , src . Files . Count ) ; var dirs_by_path = src . Dirs . ToDictionary ( x => x . AbsolutePath ) ; foreach ( var exp_dir in t . Dirs ) { CompareDir ( exp_dir , dirs_by_path [ exp_dir ] , t ) ; } var files_by_path = src . Files . ToDictionary ( x => x . GetAbsolutePath ( ) ) ; foreach ( var exp_file in t . Files ) { Assert . AreEqual ( exp_file , files_by_path [ exp_file ] . GetAbsolutePath ( ) ) ; var fi = new FileInfo ( exp_file ) ; QAssert . AreEqual ( fi . Length , files_by_path [ exp_file ] . Size ) ; QAssert . AreEqual ( fi . LastWriteTime , files_by_path [ exp_file ] . LastWriteTime ) ; } var archived_dir = src . Compress ( OutputDir , Password , 256 , log ) ; var archived = ArchivedBackup . CreateFromPath ( archived_dir , Password , log ) ; QAssert . AreEqual ( src , archived ) ; var extracted_dir = archived . Extract ( ExtractedDir , Password , log ) ; var extracted = AnalyzedBackup . Create ( extracted_dir , true , log ) ; QAssert . AreEqual ( src , extracted ) ; Directory . Delete ( src . Root . Path , true ) ; Directory . Delete ( archived_dir . Path , true ) ; Directory . Delete ( extracted_dir . Path , true ) ; }
Integration test that tests that analysis tools actually generate a correct representation of source directory,
it archives it correctly and is then able to extract it back without corrupting or losing any files.
Integration test that tests that analysis tools actually generate a correct representation of source directory it archives it correctly and is then able to extract it back without corrupting or losing any files .