private ParsedArguments GetSwitchDictionary(
            string[] args)
        {
            var result = new ParsedArguments();

            int indexOfSwitch = 0;

            while (indexOfSwitch < args.Length)
            {
                var switchArg = args[indexOfSwitch];
                var switchType = CommandlineSwitchType.GetTypeForCommandLineSwitch(switchArg);

                var indexOfSwitchValue = indexOfSwitch + 1;

                if (WeHaveMatchingCommandLineSwitch(switchType)
                    && ArgsIsLargeEnoughtToSupportSwitchValue(args, indexOfSwitchValue))

                {
                    var switchValue = args[indexOfSwitchValue];
                    result.SetValue(switchType, switchValue);
                }

                indexOfSwitch += 2;
            }

            return result;
        }
示例#2
0
        private ParsedArguments GetSwitchDictionary(
            string[] args)
        {
            var result = new ParsedArguments();

            int indexOfSwitch = 0;

            while (indexOfSwitch < args.Length)
            {
                var switchArg  = args[indexOfSwitch];
                var switchType = CommandlineSwitchType.GetTypeForCommandLineSwitch(switchArg);

                var indexOfSwitchValue = indexOfSwitch + 1;

                if (WeHaveMatchingCommandLineSwitch(switchType) &&
                    ArgsIsLargeEnoughtToSupportSwitchValue(args, indexOfSwitchValue))

                {
                    var switchValue = args[indexOfSwitchValue];
                    result.SetValue(switchType, switchValue);
                }

                indexOfSwitch += 2;
            }

            return(result);
        }
        public void HasUndoScriptFileShouldReturnTrueWhenUndoScriptFilePopulated()
        {
            var parsedArguments = new ParsedArguments();

            parsedArguments.SetValue(CommandlineSwitchType.UndoFile, "sdf");

            Assert.That(parsedArguments.HasValue(CommandlineSwitchType.UndoFile), Is.True);
        }
        public void GetScriptsFilesFolderShouldReturnScriptFolderWhenScriptFolderPopulated()
        {
            var parsedArguments = new ParsedArguments();

            parsedArguments.SetValue(CommandlineSwitchType.ScriptFiles, "c:\\foo");

            var r = parsedArguments.GetScriptFilesFolderOrDefaultFolder();

            Assert.That(r, Is.EqualTo("c:\\foo"));
        }
        public void GetUndoPrintStreamShouldReturnFileWriterWhenGivenFinalScriptFile()
        {
            var printScreenFactory = new PrintScreenFactory();

            var parsedArguments = new ParsedArguments();

            parsedArguments.SetValue(CommandlineSwitchType.UndoFile, "c:\\temp\\foo2.sql");

            TextWriter results = printScreenFactory.GetUndoPrintStream(parsedArguments);

            Assert.That(results, Is.TypeOf <StreamWriter>());

            printScreenFactory.ClosePrintStream(results);
        }