public void TestCreateWithSourceEndsOnQuote()
        {
            string[] args     = new string[2];
            string   input    = @"c:\user\joost\""";
            string   expected = @"c:\user\joost\";

            args[0] = input;
            args[1] = "somepath";

            Assert.Equal(expected, CommandLineArgumentParser.ParseArgs(args).Folders.First().Source);
        }
        public void TestLogLevel(string value, EnumLogLevel expected)
        {
            string[] args;
            if (value != "")
            {
                args    = new string[3];
                args[0] = "dummy";
                args[1] = "somepath";
                args[2] = value;
            }
            else
            {
                args    = new string[2];
                args[0] = "dummy";
                args[1] = "somepath";
            }

            Assert.Equal(expected, CommandLineArgumentParser.ParseArgs(args).LogLevel);
        }
        public void TestUpdateOnly(string value, bool expected)
        {
            string[] args;
            if (value != "")
            {
                args    = new string[3];
                args[0] = "dummy";
                args[1] = "somepath";
                args[2] = value;
            }
            else
            {
                args    = new string[2];
                args[0] = "dummy";
                args[1] = "somepath";
            }

            Assert.Equal(expected, CommandLineArgumentParser.ParseArgs(args).Folders.First().UpdatedOnly);
        }
        public void TestCreateRequestConfrm(string value, bool expected)
        {
            string[] args;
            if (value != "")
            {
                args    = new string[3];
                args[0] = "dummy";
                args[1] = "somepath";
                args[2] = value;
            }
            else
            {
                args    = new string[2];
                args[0] = "dummy";
                args[1] = "somepath";
            }

            Assert.Equal(expected, CommandLineArgumentParser.ParseArgs(args).RequestConfirm);
        }
Exemple #5
0
        public static void Main(string[] args)
        {
            try
            {
                Logger.Level = EnumLogLevel.Info;
                Logger.AddLogger(new ConsoleLogger());

                Commands theCommands = CommandLineArgumentParser.ParseArgs(args);
                if (theCommands.ShowHelp)
                {
                    Logger.Info(CommandLineArgumentParser.Help());
                }
                else
                {
                    Logger.Level = theCommands.LogLevel;
                    Logger.Info("Copy started.");
                    CommandHandler CommandHandler = new CommandHandler(theCommands);
                    Copier         Copier         = new Copier(theCommands, CommandHandler);
                    Copier.ProcessInfoEvent                   += ProcessInfo_ProcessInfoEvent;
                    CommandHandler.ProcessInfoEvent           += ProcessInfo_ProcessInfoEvent;
                    CommandHandler.ConfirmationRequestHandler += ConfirmationRequest;
                    Copier.Copy();
                    Logger.Info("Copy done.");
                    if (theCommands.PauseWhenDone)
                    {
                        Console.ReadKey();
                    }
                }
            }
            catch (System.IO.DirectoryNotFoundException ex)
            {
                Logger.Error(ex.Message);
            }
            catch (UnauthorizedAccessException ex)
            {
                Logger.Error(ex.Message);
            }
            catch (Exception ex)
            {
                Logger.Error("Failed with an unexpected exception.", ex);
            }
        }