protected void SetUp() { _executor = new DynamicMock(typeof(ProcessExecutor)); _historyParser = new DynamicMock(typeof(IHistoryParser)); _vss = new Vss(new VssLocale(CultureInfo.InvariantCulture), (IHistoryParser)_historyParser.MockInstance, (ProcessExecutor)_executor.MockInstance, null); _vss.Executable = "ss.exe"; }
protected void SetUp() { _executor = new Mock <ProcessExecutor>(); _historyParser = new Mock <IHistoryParser>(); _vss = new Vss(new VssLocale(CultureInfo.InvariantCulture), (IHistoryParser)_historyParser.Object, (ProcessExecutor)_executor.Object, null); _vss.Executable = "ss.exe"; }
public void SetUp() { CreateProcessExecutorMock(DEFAULT_SS_EXE_PATH); mockRegistry = new DynamicMock(typeof(IRegistry)); mockProcessExecutor.Strict = true; mockRegistry.SetupResult("GetExpectedLocalMachineSubKeyValue", DEFAULT_SS_EXE_PATH, typeof(string), typeof(string)); VssLocale locale = new VssLocale(CultureInfo.InvariantCulture); historyParser = new VssHistoryParser(locale); vss = new Vss(locale, historyParser, (ProcessExecutor)mockProcessExecutor.MockInstance, (IRegistry)mockRegistry.MockInstance); vss.Project = "$/fooProject"; vss.Culture = string.Empty; // invariant culture vss.Username = "******"; vss.Password = "******"; vss.WorkingDirectory = DefaultWorkingDirectory; today = DateTime.Now; yesterday = today.AddDays(-1); }
public void SetUp() { CreateProcessExecutorMock(DEFAULT_SS_EXE_PATH); mockRegistry = new Mock <IRegistry>(MockBehavior.Strict); mockRegistry.Setup(registry => registry.GetExpectedLocalMachineSubKeyValue(It.IsAny <string>(), It.IsAny <string>())).Returns(DEFAULT_SS_EXE_PATH); VssLocale locale = new VssLocale(CultureInfo.InvariantCulture); historyParser = new VssHistoryParser(locale); vss = new Vss(locale, historyParser, (ProcessExecutor)mockProcessExecutor.Object, (IRegistry)mockRegistry.Object); vss.Project = "$/fooProject"; vss.Culture = string.Empty; // invariant culture vss.Username = "******"; vss.Password = "******"; vss.WorkingDirectory = DefaultWorkingDirectory; today = DateTime.Now; yesterday = today.AddDays(-1); }
public void ShouldPopulateWithMinimalConfiguration() { vss = (Vss)NetReflector.Read("<vss />"); Assert.AreEqual(Vss.DefaultProject, vss.Project); }
public static void StartSnapshot(string jobFilePath) { JobFile job = JobFile.ReadJobFile(jobFilePath); string snapshotPath; Console.WriteLine("\nJob File Details"); Console.WriteLine("################"); Console.WriteLine("\nSources:"); foreach (string s in job.SourceDirectories) { Console.WriteLine($"{s}"); } Console.WriteLine("\nDestinations:"); foreach (string d in job.DestinationDirectories) { Console.WriteLine($"{d}"); } int jobCount = 0; foreach (string s in job.SourceDirectories) { // Debug.WriteLine jobCount++; Console.WriteLine($"\nStarting operation {jobCount} of {job.SourceDirectories.Count}"); try { Console.WriteLine("\nCreating Vss object....."); using (Vss vss = new Vss()) { Console.WriteLine($"\nGetting snapshot path for {s}....."); snapshotPath = vss.GetSnapshotPath(s); Console.WriteLine($"\nSnapshot path = {snapshotPath}"); vss.Setup(Alphaleonis.Win32.Filesystem.Path.GetPathRoot(s)); Console.Write($"\nPath Root = {Alphaleonis.Win32.Filesystem.Path.GetPathRoot(s)}"); Console.WriteLine($"\nSnapshot path is: {snapshotPath}"); foreach (string destination in job.DestinationDirectories) { try { Console.WriteLine("\nCopying from snapshot to storage destination."); string rawBackupPath = Alphaleonis.Win32.Filesystem.Path.GetFileName(s); string fullBackupPath = Alphaleonis.Win32.Filesystem.Path.Combine(destination, rawBackupPath); if (Alphaleonis.Win32.Filesystem.Directory.Exists(fullBackupPath)) { // gets rid of the previous backup if exists ^^ <-- is this redundant to the following block??? Alphaleonis.Win32.Filesystem.Directory.Delete(fullBackupPath, true, true); Alphaleonis.Win32.Filesystem.Directory.CreateDirectory(fullBackupPath); Alphaleonis.Win32.Filesystem.Directory.Copy(snapshotPath, fullBackupPath, true); } else { Alphaleonis.Win32.Filesystem.Directory.CreateDirectory(fullBackupPath); Alphaleonis.Win32.Filesystem.Directory.Copy(snapshotPath, fullBackupPath, true); } Console.WriteLine("\nBackup completed."); } catch (UnauthorizedAccessException e) { // log event Console.WriteLine($"\nUnauthorized exception: {e}"); } } } } catch (Exception e) { Console.WriteLine($"\nError: {e}"); Debug.WriteLine("\nError when trying to create Vss:" + e); } } }