コード例 #1
0
        public async Task RunRemoteBackupTest()
        {
            var settings = new BackupManagerSettings();

            settings.Locations.Add(RemoteLocationInfo);
            BackupManager = BackupManagerFactory.GetBackupManager(CatalogPath, settings);
            BackupManager.AddDirectoryToCatalog(new BackupDirectory(TestTwoPath));
            //BackupManager.AddDirectoryToCatalog(new BackupDirectory(TestOnePath));

            var serverWatchDog = new WatchDog();
            var comminicator   = new Communicator(13001, new NetworkClient("TestServer", new TcpClient()), new NetworkListener());
            var fileServer     = new RemoteFileServer(comminicator, RemoteStoragePath, RemoteTemporaryStoragePath);
            var backupService  = new BackupServiceModule(fileServer);

            serverWatchDog.RegisterModule(backupService);
            await serverWatchDog.Start();

            await BackupManager.RunBackup();

            BackupManager.SaveCatalog();

            //var storageLocationFactory = Container.Resolve<IStorageLocationFactory>();
            var location = BackupManager.GetLocations().First();
            //await BackupManager.RestoreBackupSet(location, TestOnePath, RestorePath);
            await BackupManager.RestoreBackupSet(location, TestTwoPath, RestorePath);

            var originalFile = new FileInfo(FileToRestorePath);
            var restoredFile = new FileInfo(PathToRestoreFile);

            Assert.AreEqual(originalFile.Length, restoredFile.Length);
            Assert.AreEqual(originalFile.Attributes, restoredFile.Attributes);
            Assert.AreEqual(originalFile.CreationTime, restoredFile.CreationTime);
            Assert.AreEqual(originalFile.LastWriteTime, restoredFile.LastWriteTime);
            Assert.AreEqual(originalFile.IsReadOnly, restoredFile.IsReadOnly);
        }
コード例 #2
0
        public void RunLocalBackupTest()
        {
            var settings = new BackupManagerSettings();

            settings.Locations.Add(LocalLocationInfo);
            BackupManager = BackupManagerFactory.GetBackupManager(CatalogPath, settings);
            BackupManager.AddDirectoryToCatalog(new BackupDirectory(TestTwoPath));
            BackupManager.AddDirectoryToCatalog(new BackupDirectory(TestOnePath));
            BackupManager.RunBackup();
            BackupManager.SaveCatalog();

            var storageLocationFactory = Container.Resolve <IStorageLocationFactory>();
            var location = storageLocationFactory.GetStorageLocation(LocalLocationInfo);

            BackupManager.RestoreBackupSet(location, TestOnePath, RestorePath);
            BackupManager.RestoreBackupSet(location, TestTwoPath, RestorePath);

            var originalFile = new FileInfo(FileToRestorePath);
            var restoredFile = new FileInfo(PathToRestoreFile);

            Assert.AreEqual(originalFile.Length, restoredFile.Length);
            Assert.AreEqual(originalFile.Attributes, restoredFile.Attributes);
            Assert.AreEqual(originalFile.CreationTime, restoredFile.CreationTime);
            Assert.AreEqual(originalFile.LastWriteTime, restoredFile.LastWriteTime);
            Assert.AreEqual(originalFile.IsReadOnly, restoredFile.IsReadOnly);
        }