Ejemplo n.º 1
0
        public void RevertWithFileDeletion()
        {
            this.TestInitialize();
            string[] lines = { "First line", "Second line", "Third line" };
            System.IO.File.WriteAllLines(@"asd\ciao\tre.txt", lines);

            FBVersionBuilder vb = new FBVersionBuilder(rinfo.FullName);

            FolderBackup.Shared.FBVersion v = (FolderBackup.Shared.FBVersion)vb.generate();

            SerializedVersion serV = new SerializedVersion(v.serialize());

            server.newTransaction(serV);

            server.commit();

            UploadData ud = server.resetToPreviousVersion(1);

            UsefullMethods.ReceiveFile(ud.ip, ud.port, ud.token, @"asd\asd.zip");

            String             ignore;
            List <Instruction> instructionList = UsefullMethods.ExtractInstructions(@"asd\asd.zip", out ignore);

            Assert.IsTrue(instructionList.Count == 1);
            Assert.IsTrue(instructionList[0].cmd == InstructionType.DELETE);
            Assert.IsTrue(instructionList[0].src == @"ciao\tre.txt");
        }
Ejemplo n.º 2
0
        private void resetVersion(UploadData ud, FBVersion v)
        {
            string filename = Path.GetTempFileName();

            UsefullMethods.ReceiveFile(ud.ip, ud.port, ud.token, filename);

            String             pathFiles;
            List <Instruction> instructionList = UsefullMethods.ExtractInstructions(filename, out pathFiles);

            instructionList.Sort((emp1, emp2) => emp1.cmd.CompareTo(emp2.cmd));
            foreach (Instruction i in instructionList)
            {
                ExecuteInstruction(i, pathFiles);
            }
            CleanUpDir(v.root, "");
            StartSync();
        }
Ejemplo n.º 3
0
        public void RevertWithNewFile()
        {
            this.TestInitialize();
            string[] lines = { "First line", "Second line", "Third line", "Fourth line" };
            System.IO.File.WriteAllLines(@"asd\ciao\tre.txt", lines);

            FBVersionBuilder vb = new FBVersionBuilder(rinfo.FullName);

            FolderBackup.Shared.FBVersion v = (FolderBackup.Shared.FBVersion)vb.generate();

            SerializedVersion serV = new SerializedVersion(v.serialize());

            server.newTransaction(serV);
            FileStream fstream = new FileStream(@"asd\ciao\tre.txt", FileMode.Open, FileAccess.Read);

            server.getFilesToUpload();
            UploadData credential = server.uploadFile();

            UsefullMethods.SendFile(credential.ip, credential.port, credential.token, fstream);
            server.commit();

            System.IO.File.Delete(@"asd\ciao\tre.txt");
            vb   = new FBVersionBuilder(rinfo.FullName);
            v    = (FolderBackup.Shared.FBVersion)vb.generate();
            serV = new SerializedVersion(v.serialize());

            server.newTransaction(serV);

            server.commit();

            UploadData ud = server.resetToPreviousVersion(1);

            UsefullMethods.ReceiveFile(ud.ip, ud.port, ud.token, @"asd\asd.zip");

            String             ignore;
            List <Instruction> instructionList = UsefullMethods.ExtractInstructions(@"asd\asd.zip", out ignore);

            Assert.IsTrue(instructionList.Count == 1);
            Assert.IsTrue(instructionList[0].cmd == InstructionType.NEW);
            Assert.IsTrue(instructionList[0].dst == @"ciao\tre.txt");
        }