public void Initialize()
 {
     _targetDir        = new TemporaryDirectory();
     _backupDir        = new TemporaryDirectory();
     _tempDir          = new TemporaryDirectory();
     _filePatcher      = new XdeltaPatcher(XdeltaPatchSystemFactory.Preferred);
     _patchSource      = new FileSystemPatchSource(_patchDir.Path);
     _directoryPatcher = new DirectoryPatcher(_filePatcher, _targetDir.Path, _backupDir.Path, _tempDir.Path, _patchSource);
 }
Esempio n. 2
0
        public async Task TestRoundtrip()
        {
            var patchSystem  = XdeltaPatchSystemFactory.Preferred;
            var patchBuilder = new XdeltaPatchBuilder(patchSystem);
            var patcher      = new XdeltaPatcher(patchSystem);

            using (var oldFile = new TemporaryFile())
                using (var newFile = new TemporaryFile())
                    using (var patchFile = new TemporaryFile())
                        using (var patchedFile = new TemporaryFile())
                        {
                            File.WriteAllText(oldFile.Path, "old");
                            File.WriteAllText(newFile.Path, "new");
                            await patchBuilder.CreatePatchAsync(oldFile.Path, newFile.Path, patchFile.Path);

                            await patcher.ApplyPatchAsync(oldFile.Path, patchedFile.Path, patchFile.Path);

                            Assert.AreEqual("new", File.ReadAllText(patchedFile.Path));
                        }
        }