public void ResolveToRemote() { TestConflictResolver tcr = new TestConflictResolver(); tcr.Mode = TestConflictResolver.ResolutionMode.KeepRemote; ResolveConflictCallback rccb = new ResolveConflictCallback(tcr.ResolveConflict); sync.Resolve(rccb); Assert.AreEqual(Status.LocallyModified, theTopic.Status, "Checking that status is now LocallyModified"); Assert.AreEqual(remoteContents, Utilities.GetTopicContent(theTopic), "Checking that local contents were overwritten"); }
public void ResolveToLocal() { TestConflictResolver tcr = new TestConflictResolver(); tcr.Mode = TestConflictResolver.ResolutionMode.KeepLocal; ResolveConflictCallback rccb = new ResolveConflictCallback(tcr.ResolveConflict); sync.Resolve(rccb); Assert.AreEqual(Status.LocallyModified, theTopic.Status, "Checking that status is now LocallyModified"); Assert.AreEqual(localContents, Utilities.GetTopicContent(theTopic), "Checking that local contents were kept"); ArrayList events = target.Find(EventType.ConflictSkipped); Assert.AreEqual(0, events.Count, "Checking that no conflicts were reported skipped"); }
public void ResolveCancelled() { TestConflictResolver tcr = new TestConflictResolver(); tcr.Mode = TestConflictResolver.ResolutionMode.Cancel; ResolveConflictCallback rccb = new ResolveConflictCallback(tcr.ResolveConflict); sync.Resolve(rccb); Assert.AreEqual(Status.InConflict, theTopic.Status, "Checking that status is still InConflict"); Assert.AreEqual(localContents, Utilities.GetTopicContent(theTopic), "Checking that local contents were unchanged"); }
public void ResolveConcatenate() { TestConflictResolver tcr = new TestConflictResolver(); tcr.Mode = TestConflictResolver.ResolutionMode.Concatenate; ResolveConflictCallback rccb = new ResolveConflictCallback(tcr.ResolveConflict); sync.Resolve(rccb); Assert.AreEqual(Status.LocallyModified, theTopic.Status, "Checking that status is now LocallyModified"); Assert.AreEqual(localContents + remoteContents, Utilities.GetTopicContent(theTopic), "Checking that local and remote contents were 'merged'"); }
public static int Main(string[] args) { try { PrintCopyright(); string envOptions = Environment.GetEnvironmentVariable("FWSOPTIONS"); if (envOptions != null) { envOptions = envOptions.Trim(); if (envOptions.Length > 0) { string[] additionalArgs = envOptions.Split(' '); ArrayList al = new ArrayList(); al.AddRange(additionalArgs); al.AddRange(args); args = (string[]) al.ToArray(typeof(string)); Console.WriteLine("Running with modified command line:"); Console.WriteLine("fwsync {0}", string.Join(" ", args)); } } Options options = null; GetPasswordCallback gpc = new GetPasswordCallback(GetPassword); try { options = Utilities.ParseCommandLine(args, gpc); } catch (ParseCommandLineException pcle) { Console.WriteLine(pcle.Message); Utilities.PrintUsage(); return ERROR_USAGE; } if (options.Debug) { System.Diagnostics.Debugger.Break(); } FwEditServiceProxy proxy = CreateEditServiceProxy(options); string basedir = Synchronizer.CalculateBaseDir(options.Files); Synchronizer sync = new Synchronizer(basedir, proxy); sync.Progress += new ProgressCallback(PrintProgress); if (options.Command == Commands.Initialize) { sync.Initialize(options.LocalOnly); } else if (options.Command == Commands.Update) { sync.Update(options.Files); } else if (options.Command == Commands.Status) { sync.SyncToLocal(); if (!options.LocalOnly) { sync.SyncToRemote(); } PrintStatus(sync, options.Files, options.Show); } else if (options.Command == Commands.Commit) { try { sync.Commit(options.Attribution, options.Files, options.IgnoreConflict); } catch (ConflictException c) { Console.WriteLine(c.Message); return ERROR_CONFLICT; } } else if (options.Command == Commands.Help) { switch (options.HelpTopic) { case HelpTopics.Commands: Utilities.PrintCommandsHelp(); break; case HelpTopics.Commit: Utilities.PrintCommitHelp(); break; case HelpTopics.Environment: Utilities.PrintEnvironmentHelp(); break; case HelpTopics.General: Utilities.PrintGeneralHelp(); break; case HelpTopics.Help: Utilities.PrintHelpHelp(); break; case HelpTopics.Init: Utilities.PrintInitHelp(); break; case HelpTopics.Options: Utilities.PrintOptionsHelp(); break; case HelpTopics.Status: Utilities.PrintStatusHelp(); break; case HelpTopics.Resolve: Utilities.PrintResolveHelp(); break; case HelpTopics.Update: Utilities.PrintUpdateHelp(); break; default: Utilities.PrintGeneralHelp(); break; } } else if (options.Command == Commands.Resolve) { ConflictResolver cr = new ConflictResolver(options); ResolveConflictCallback rccb = new ResolveConflictCallback(cr.ResolveConflict); sync.Resolve(rccb, options.Files); } else { Console.WriteLine("Command {0} not currently implemented", options.Command); return ERROR_NOT_IMPLEMENTED; } } catch (Exception e) { Console.WriteLine("An unhandled exception was thrown.\n\n{0}", e); return ERROR_EXCEPTION; } return SUCCESS; }