public void TestCommandLineParserWrongNameForExportModeValueError()
        {
            var args   = new[] { "--db-server", "name", "--mode", "export-al", "--folder", "c://..." };
            var result = CmdParser.Parse(args);

            Assert.AreEqual(result.IsSuccess, false);
        }
        public void TestCommandLineParserExampleOfWorkingOfImportList()
        {
            var args   = new[] { "--m", "import-list", "--db-server", "WRK-003", "--r", @"C:\Users\v.michailov\RealProjects\biztalkutilites\outputData\file.xml" };
            var result = CmdParser.Parse(args);
            var same   = new Args
            {
                Mode = Mode.ImportList,
            };

            same.RuleNames.Add(new BreRecord()
            {
                FullFileName = @"C:\temp\file.xml"
            });
            same.RuleNames.Add(new BreRecord()
            {
                FullFileName = @"C:\temp\file2.xml"
            });
            same.ServerName = "WRK-003";
            same.DbName     = "BizTalkRuleEngineDb";
            Assert.AreEqual(result.ServerName, same.ServerName);
            Assert.AreEqual(result.DbName, same.DbName);
            Assert.AreEqual(result.Mode, same.Mode);
            Assert.AreEqual(result.Errors.Count == 0, same.Errors.Count == 0);
            Assert.AreEqual(result.Path, same.Path);
            Assert.AreEqual(result.IsOverwrite, same.IsOverwrite);
            for (var i = 0; i < result.RuleNames.Count; i++)
            {
                Assert.AreEqual(result.RuleNames[i].Name, same.RuleNames[i].Name);
                Assert.AreEqual(result.RuleNames[i].MajorRevision, same.RuleNames[i].MajorRevision);
                Assert.AreEqual(result.RuleNames[i].MinorRevision, same.RuleNames[i].MinorRevision);
                Assert.AreEqual(result.RuleNames[i].UseMaxVersion, same.RuleNames[i].UseMaxVersion);
                Assert.AreEqual(result.RuleNames[i].FullFileName, same.RuleNames[i].FullFileName);
            }
        }
        public void TestCommandLineParserWithoutValueForArgumentError()
        {
            var args   = new[] { "--db-server", "name", "--mode", "import-list", "--rule-names" };
            var result = CmdParser.Parse(args);

            Assert.AreEqual(result.IsSuccess, false);
        }
Exemple #4
0
 private static void Main(string[] args)
 {
     CmdParser.Parse(args,
                     on3CmdParameter: CmdMode.Start,
                     onNoCmdParameter: GUI.Open,
                     onError: Console.WriteLine);
 }
        public void TestCommandLineParserWithoutValueForRequiredArgumentsError()//MissingRequiredOptionError + MissingValueOptionError
        {
            var args   = new[] { "--db-server", "name", "--mode" };
            var result = CmdParser.Parse(args);

            Assert.AreEqual(result.IsSuccess, false);
        }
        public void CmdParser_Parse_FileFlagRequired(string[] args)
        {
            var exception = Assert.ThrowsException <Exception>(() => {
                CmdParser.Parse(args);
            });

            Assert.AreEqual("The flag -File is required.", exception.Message);
        }
        public void TestCommandLineParserWithShortCommand()
        {
            var args   = new[] { "--m", "export-list", "--d", "WRK-003", "--f", @"..\..\..\inputData", "--r", "voc1", "--n", "BizTalkRuleEngineDb", "--w" };
            var result = CmdParser.Parse(args);

            RuleReadWriter.Write(result.ServerName, result.DbName, result.RuleNames, result.Path, TODO);
            Assert.AreEqual(result.IsSuccess, true);
            File.Delete(@"..\..\..\inputData\voc1-1.0.xml");
        }
        public void CmdParser_Parse_Success(string fileFlag, string fileValue, string sortByDateFlag, string projectFlag, string projectValue)
        {
            var args = new string[] { fileFlag, fileValue, sortByDateFlag, projectFlag, projectValue };

            var result = CmdParser.Parse(args);

            Assert.AreEqual(fileValue, result.FilePath);
            Assert.AreEqual(sortByDateFlag != null, result.SortByDate);
            Assert.AreEqual(projectValue?.ToString(), result.Project?.ToString());
        }
        public void CmdParser_Parse_FileValueRequired()
        {
            var args = new string[] { "-File" };

            var exception = Assert.ThrowsException <Exception>(() => {
                CmdParser.Parse(args);
            });

            Assert.AreEqual("No value was provided for the argument flag -File.", exception.Message);
        }
        public void CmdParser_Parse_InvalidProjectValueType()
        {
            var args = new string[] { "-File", @"..\..\..\Files\Data.tsv", "-Project", "a" };

            var exception = Assert.ThrowsException <Exception>(() => {
                CmdParser.Parse(args);
            });

            Assert.AreEqual("The value a is not valid for flag -Project.", exception.Message);
        }
Exemple #11
0
        public void TestCommandLineParserWithoutRuleNamesError()
        {
            var args   = new[] { "--db-server", "name", "--mode", "import-list", "--folder", "c://..." };
            var result = CmdParser.Parse(args);

            Assert.AreEqual(result.Errors.Contains(new LogicErrorType(ErrorType.UnknownOptionError)), true);

            var args2   = new[] { "--db-server", "name", "--mode", "export-list", "--folder", "c://..." };
            var result2 = CmdParser.Parse(args2);

            Assert.AreEqual(result2.Errors.Contains(new LogicErrorType(ErrorType.UnknownOptionError)), true);
        }
Exemple #12
0
        public void TestCommandLineParserWrongNameArgumentsError()//UnknownOptionError
        {
            var args   = new[] { "--db-server", "name", "--mode", "export-list", "--rule-na", "--folder", "c://..." };
            var result = CmdParser.Parse(args);

            Assert.AreEqual(result.IsSuccess, false);

            var args2   = new[] { "--db-server", "name", "--mod", "export-list", "--rule-names", "name,version;name", "--folder", "c://..." };
            var result2 = CmdParser.Parse(args2);

            Assert.AreEqual(result2.IsSuccess, false);
        }
        public static Bitmap Get(string path, int scaleRatio, Brush brush, SmoothingMode mode = SmoothingMode.HighQuality)
        {
            int        svgPathSize = 8;
            int        width       = svgPathSize * scaleRatio + 1;
            int        height      = svgPathSize * scaleRatio + 1;
            List <Cmd> cmds;

            cmds = CmdParser.Parse(path);
            CmdValidator.ValidateCmds(cmds);
            cmds = CmdConverter.ExtractToSingleAndAbsolutePositionCmds(cmds);
            cmds = CmdScaler.Scale(cmds, scaleRatio);
            return(CmdDrawer.Draw(cmds, width, height, brush, mode));
        }
Exemple #14
0
        public void TestCommandLineParserWithRequiredArguments()
        {
            var args   = new[] { "--mode", "export-all", "--db-server", "name" };
            var result = CmdParser.Parse(args);
            var same   = new Args
            {
                ServerName = "name",
                Mode       = Mode.ExportAll
            };

            Assert.AreEqual(result.Mode, same.Mode);
            Assert.AreEqual(result.ServerName, same.ServerName);
            Assert.AreEqual(result.RuleNames.Length == 0, same.RuleNames.Length == 0);
        }
        public static int Main(string[] args)
        {
            var handle = GetStdHandle(-11);

            AttachConsole(-1);

            CmdParser.Parse(args);
            if (CmdParser.LaunchApp)
            {
                var App = new App();
                App.InitializeComponent();
                App.Run();
            }
            return(0);
        }
Exemple #16
0
        public void TestCommandLineParserWithotRequiredArgumentsError()//MissingRequiredOptionError
        {
            var args   = new[] { "--db-server", "name", "--folder", "c://..." };
            var result = CmdParser.Parse(args);

            Assert.AreEqual(result.IsSuccess, false);

            var args2 = new[] { "--mode", "import-all", "--folder", "c://..." };

            result = CmdParser.Parse(args2);
            Assert.AreEqual(result.IsSuccess, false);

            var args3 = new[] { "--mode", "export-list" };

            result = CmdParser.Parse(args3);
            Assert.AreEqual(result.IsSuccess, false);
        }
Exemple #17
0
        static void Main(string[] args)
        {
            try
            {
                var arguments = CmdParser.Parse(args);

                var output = InputParser.Parse(arguments.FilePath);

                output = FilterHandler.Filter(output, arguments);

                OutputPrinter.Print(output);

                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadKey();
            }
        }
Exemple #18
0
        public void TestCommandLineParserUsingMaxVersion()
        {
            var args   = new[] { "--mode", "export-list", "--db-server", "name", "--rule-names", "rName1" };
            var result = CmdParser.Parse(args);
            var same   = new Args
            {
                Mode       = Mode.ExportList,
                BreRecords = new List <BreRecord>()
            };
            var rule = new BreRecord()
            {
                UseMaxVersion = true
            };

            same.RuleNames.Add(rule);
            Assert.AreEqual(result.Mode, same.Mode);
            for (var i = 0; i < result.RuleNames.Count; i++)
            {
                Assert.AreEqual(result.RuleNames[i].UseMaxVersion, same.RuleNames[i].UseMaxVersion);
            }
        }
Exemple #19
0
        private void Preview()
        {
            try
            {
                lblError.Text = string.Empty;
                //
                int scale = (int)nudScale.Value;
                _cmds = CmdParser.Parse(txtSVGPath.Text);
                List <Cmd> processedCmds = _cmds;
                processedCmds = CmdConverter.ExtractToSingleAndAbsolutePositionCmds(processedCmds);
                processedCmds = CmdScaler.Scale(processedCmds, scale);
                // load parse command into listview
                lbParsedCmds.SelectedIndexChanged -= lbParsedCmds_SelectedIndexChanged;
                lbParsedCmds.Items.Clear();
                lbParsedCmds.Items.AddRange(
                    _cmds
                    .Select(i => i.ToString())
                    .ToArray());
                lbParsedCmds.SelectedIndexChanged += lbParsedCmds_SelectedIndexChanged;

                // select last events
                lbParsedCmds.SelectedIndex = lbParsedCmds.Items.Count - 1;
            }
            catch (InvalidSvgCharacterException isce)
            {
                pbPreview.Image = null;
                lblError.Text   = "Error: " + isce.Message;
            }
            catch (InvalidCmdException invalidCmdEx)
            {
                pbPreview.Image            = null;
                lbParsedCmds.SelectedIndex = invalidCmdEx.Index;
                lblError.Text = "Error: " + invalidCmdEx.Message;
            }
            catch (Exception ex)
            {
                lblError.Text = "Error: " + ex.Message;
            }
        }
Exemple #20
0
        public void TestCommandLineParserWithAllArgumentstAndExampleOfWorkingExportList()
        {
            var args   = new[] { "--m", "export-list", "--db-server", "WRK-003", "--r", "aa,1.0;bb", "--f", @"c:\temp", "--w" };
            var result = CmdParser.Parse(args);
            var same   = new Args
            {
                Mode = Mode.ExportList,
            };

            same.RuleNames.Add(new BreRecord()
            {
                FullFileName = $"aa-{1}.{0}.xml"
            });
            same.RuleNames.Add(new BreRecord()
            {
                UseMaxVersion = true
            });
            same.ServerName  = "name";
            same.DbName      = "BizTalkRuleEngineDb";
            same.Path        = @"c:\temp\";
            same.IsOverwrite = true;
            Assert.AreEqual(result.ServerName, same.ServerName);
            Assert.AreEqual(result.DbName, same.DbName);
            Assert.AreEqual(result.Mode, same.Mode);
            Assert.AreEqual(result.Errors.Count == 0, same.Errors.Count == 0);
            Assert.AreEqual(result.Path, same.Path);
            Assert.AreEqual(result.IsOverwrite, same.IsOverwrite);
            for (var i = 0; i < result.RuleNames.Count; i++)
            {
                Assert.AreEqual(result.RuleNames[i].Name, same.RuleNames[i].Name);
                Assert.AreEqual(result.RuleNames[i].MajorRevision, same.RuleNames[i].MajorRevision);
                Assert.AreEqual(result.RuleNames[i].MinorRevision, same.RuleNames[i].MinorRevision);
                Assert.AreEqual(result.RuleNames[i].UseMaxVersion, same.RuleNames[i].UseMaxVersion);
                Assert.AreEqual(result.RuleNames[i].FullFileName, same.RuleNames[i].FullFileName);
            }
        }
Exemple #21
0
        private static void Main(string[] args)
        {
            var files = new List <BreRecord>();

            RuleReadWriter.Error += ShowMsqError;
            var parseArgs = CmdParser.Parse(args);

            if (!parseArgs.IsSuccess)
            {
                foreach (var error in parseArgs.Errors)
                {
                    switch (error.Tag)
                    {
                    case ErrorType.UnknownOptionError:
                        foreach (var err in parseArgs.Errors)
                        {
                            if (!(err is LogicErrorType))
                            {
                                continue;
                            }
                            Console.WriteLine("отсутствует --rule-names");
                            Console.ReadLine();
                        }
                        break;

                    case ErrorType.BadFormatTokenError:
                        Console.WriteLine("Ошибка имени значения ключа --mode");
                        Console.ReadLine();
                        break;

                    case ErrorType.BadVerbSelectedError:
                        Console.WriteLine("не указан путь");
                        Console.ReadLine();
                        break;

                    default:
                        throw new Exception("Неизвестная ошибка");
                    }
                }
            }
            switch (parseArgs.Mode)
            {
            case Mode.ExportAll:
                files = RuleReadWriter.CreateFileForWriteAll(parseArgs.ServerName, parseArgs.DbName);
                RuleReadWriter.Write(parseArgs.ServerName, parseArgs.DbName, files, parseArgs.Path, parseArgs.IsOverwrite);
                break;

            case Mode.ExportList:
                foreach (var name in parseArgs.RuleNames)
                {
                    var fileList = RuleReadWriter.CreateFileForWriteList(parseArgs.ServerName, parseArgs.DbName, RuleReadWriter.CreateRecord(name));
                    foreach (var file in fileList)
                    {
                        files.Add(file);
                    }
                }
                RuleReadWriter.Write(parseArgs.ServerName, parseArgs.DbName, files, parseArgs.Path, parseArgs.IsOverwrite);
                break;

            case Mode.ImportAll:
                RuleReadWriter.Read(parseArgs.ServerName, parseArgs.DbName, RuleReadWriter.CreateFileForReadAll(parseArgs.Path));
                break;

            case Mode.ImportList:
                foreach (var name in parseArgs.RuleNames)
                {
                    files.Add(RuleReadWriter.CreateFileForReadList(name));
                }
                RuleReadWriter.Read(parseArgs.ServerName, parseArgs.DbName, files);
                break;

            case Mode.ShowList:
                foreach (var name in parseArgs.RuleNames)
                {
                    files.Add(RuleReadWriter.CreateRecord(name));
                }
                RuleEngineDb.ShowListRuleAndVocab(files, parseArgs.IsDependecy);
                break;

            case Mode.ShowAll:
                RuleEngineDb.ShowAllRuleAndVocab(parseArgs.IsDependecy);
                break;
            }
        }