예제 #1
0
파일: Program.cs 프로젝트: egecorp/CVRobots
        static void Main(string[] args)
        {
            System.Console.WriteLine("Input data");
            ConsoleParser cp = new ConsoleParser();
            bool          needContinue;

            do
            {
                try
                {
                    string inputString = System.Console.ReadLine();
                    needContinue = cp.Input(inputString);
                }
                catch (Exception e)
                {
                    System.Console.WriteLine(e.Message);
                    System.Console.WriteLine("Programm will be restarted");
                    cp.Clear();
                    needContinue = true;
                }
            }while (needContinue);

            System.Console.WriteLine("Programm finished. Press Enter...");
            System.Console.ReadLine();
        }
        private bool executeABCM2PS()
        {
            string errOutput = ConsoleParser.ExecuteCommand(
                "\"" + StringConstants.ABCM2PS + "\"",
                "-c -g -w " + (this.pictureBox.Width - 90) + " -m 0 \"" + StringConstants.TEMP_ABC + "\" -O \"" + StringConstants.TEMP_SVG_WRITE + "\"");

            string[] multilineseparator = { "\r\n", "\n" };
            char[]   wordseparator      = { ' ' };
            string[] lines = errOutput.Split(multilineseparator, StringSplitOptions.RemoveEmptyEntries);

            bool output = false;

            //Search errors
            for (int i = 0; i < lines.Length; i++)
            {
                string[] line_words = lines[i].Split(wordseparator, StringSplitOptions.RemoveEmptyEntries);
                if (line_words.Length > 1 && line_words[1] == "error:")
                {
                    List <string> aux = line_words.ToList();
                    aux.RemoveAt(0); aux.RemoveAt(0);
                    string err_type = string.Join(" ", aux.ToArray());
                    if (!validError(err_type))
                    {
                        return(false);
                    }
                }
                else if (line_words[0] == "Output")
                {
                    output = true;
                }
            }

            return(output);
        }
예제 #3
0
        public void Test()
        {
            var ua            = @"Mozilla/5.0 (Linux; Android 4.2.2; ARCHOS 101 PLATINUM Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Safari/537.36";
            var consoleParser = new ConsoleParser();

            consoleParser.SetUserAgent(ua);
            var result = consoleParser.Parse();
        }
예제 #4
0
        public void have_an_integer_when_second_line_is_read()
        {
            int nbrExchangeRates = ConsoleParser.ReadSecondLine("6");

            nbrExchangeRates.ShouldSatisfyAllConditions
            (
                () => nbrExchangeRates.ShouldBeOfType(typeof(Int32)),
                () => nbrExchangeRates.ShouldBeGreaterThan(0)

            );
        }
예제 #5
0
        public void have_3_elements_when_first_line_is_read()
        {
            Tuple <string, int, string> firstLineElements = ConsoleParser.ReadFirstLine("EUR;550;JPY");

            firstLineElements.ShouldSatisfyAllConditions
            (
                () => firstLineElements.Item1.ShouldBe("EUR"),
                () => firstLineElements.Item2.ShouldBe(550),
                () => firstLineElements.Item3.ShouldBe("JPY")
            );
        }
예제 #6
0
        public void have_3_elements_when_third_line_is_read()
        {
            Tuple <string, string, decimal> exchangeRateLineElements = ConsoleParser.ReadExchangeRatesLine("AUD;CHF;0.9661");

            exchangeRateLineElements.ShouldSatisfyAllConditions
            (
                () => exchangeRateLineElements.Item1.ShouldBe("AUD"),
                () => exchangeRateLineElements.Item2.ShouldBe("CHF"),
                () => exchangeRateLineElements.Item3.ShouldBe(0.9661m)
            );
        }
예제 #7
0
        private static void Main(string[] args)
        {
            InitialiseConsole();
            var        commands = new ConsoleParser().GetCommands();
            var        table    = new Table(5, 5);
            TextWriter writer   = new StringWriter();

            new Processor(writer).Process(table, commands);

            WriteOutput(writer);

            Console.ReadLine();
        }
예제 #8
0
        private static void MigrateBusRoute()
        {
            var             filename = "BusRoute.csv";
            List <BusRoute> routes   = ConsoleParser.For(new BusRouteCSVParser()).Parse(filename);

            var converter = new OSGB36ToWGS84();

            converter.ConvertRoutes(routes);

            RavenDocumentStoreSessionOperation(session => routes.ForEach(session.Store));

            Console.WriteLine("Successfully saved {0} routes.", routes.Count);
        }
예제 #9
0
        public void ConsoleTestParse()
        {
            var consoleParser = new ConsoleParser();

            foreach (var fixture in _fixtureData)
            {
                consoleParser.SetUserAgent(fixture.user_agent);
                var result = consoleParser.Parse();
                result.Success.Should().BeTrue("Match should be with success to " + fixture.device.model);

                result.Match.Name.Should().BeEquivalentTo(fixture.device.model, "Names should be equal");
                result.Match.Brand.Should().BeEquivalentTo(fixture.device.brand, "Brand should be equal");
                result.Match.Type.Should().Be(fixture.device.type, "Types should be equal");
            }
        }
    /// <summary>
    /// Initializes any required objects.
    /// </summary>
    private void Awake()
    {
        if (parser == null)
        {
            parser = new ConsoleParser(outputHistorySize);
        }

        if (animator == null)
        {
            animator         = background.gameObject.GetComponent <Animator>();
            animator.enabled = false;
        }

        DontDestroyOnLoad(transform.parent.gameObject);
    }
예제 #11
0
        static void Main(string[] args)
        {
            try
            {
                var options = CommandSerializer <CommandArgs> .Parse(args);

                options.Validate();

                try
                {
                    var parser = new ConsoleParser();
                    parser.Init(options.Countries);
                    var listOption     = options.Recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
                    var files          = (from file in Directory.EnumerateFiles(options.Input, "*.*", listOption) select file).ToList();
                    var remainingFiles = parser.Filter(files);

                    if (options.Help)
                    {
                        Console.Out.WriteLine(CommandSerializer <CommandArgs> .GetHelp(Console.WindowWidth));
                    }
                    else if (options.Stats)
                    {
                        Console.Out.WriteLine(options.GetSummary(files, remainingFiles));
                    }
                    else
                    {
                        Copy(remainingFiles, options);
                    }
                }
                catch (Exception ex)
                {
                    Console.Out.WriteLine(ex);
                }
            }
            catch (Exception)
            {
                Console.Out.WriteLine(CommandSerializer <CommandArgs> .GetHelp(Console.WindowWidth));
            }
        }
예제 #12
0
        public void ParseAllSteps_Success()
        {
            IStandardIOReaderWriter consoleMock = Substitute.For <IStandardIOReaderWriter>();

            consoleMock
            .ReadLine().Returns(
                "4",            // the number of directional commands to process
                "10 20",        // the starting point coordinate
                "E 2",          // from there and below follow navigation commands
                "E 5",
                "W 3",
                "S 7",
                "S 7",
                "whatever invalid argument won't be processed as we retrieve only the first four directional parameters");

            var sut          = new ConsoleParser(consoleMock);
            var inputCommand = sut.ParseAllSteps();

            Assert.IsTrue(inputCommand.StartingCoordinate.X == 10);
            Assert.IsTrue(inputCommand.StartingCoordinate.Y == 20);
            Assert.IsTrue(inputCommand.AtomicNavigationSteps.Count == 17);

            consoleMock.Received(6).ReadLine(); // we invoked the ReadLine only 6 = 2 + 4 times regardless of how many additional navigation parameters we supplied
        }
예제 #13
0
        public void return_null_when_third_line_is_read_is_empty()
        {
            Tuple <string, string, decimal> exchangeRateLineElements = ConsoleParser.ReadExchangeRatesLine("");

            exchangeRateLineElements.ShouldBe(null);
        }
예제 #14
0
 public void savePDF(string pdfPath)
 {
     AbcFileWriter.saveToFile(this.tune, StringConstants.TEMP_ABC, getTempo(), false);
     ConsoleParser.ExecuteCommand("\"" + StringConstants.ABCM2PS + "\"", "-c -g \"" + StringConstants.TEMP_ABC + "\" -E -O \"" + StringConstants.TEMP_EPS_WRITE + "\"");
     ConsoleParser.ExecuteCommand("\"" + StringConstants.EPSTOPDF + "\"", "--outfile=\"" + pdfPath + "\" \"" + StringConstants.TEMP_EPS_READ + "\"");
 }
예제 #15
0
        public void return_null_when_third_line_is_read_and_amount_is_lower_than_0()
        {
            Tuple <string, string, decimal> exchangeRateLineElements = ConsoleParser.ReadExchangeRatesLine("AUD;CHF;-1.3");

            exchangeRateLineElements.ShouldBe(null);
        }
예제 #16
0
        public void return_null_when_first_line_is_read_is_empty()
        {
            Tuple <string, int, string> firstLineElements = ConsoleParser.ReadFirstLine("");

            firstLineElements.ShouldBe(null);
        }
예제 #17
0
        public void return_null_when_first_line_is_read_does_not_contain_3_elements()
        {
            Tuple <string, int, string> firstLineElements = ConsoleParser.ReadFirstLine("ZZZ;333");

            firstLineElements.ShouldBe(null);
        }
예제 #18
0
        public void return_null_when_first_line_is_read_and_amount_not_an_integer()
        {
            Tuple <string, int, string> firstLineElements = ConsoleParser.ReadFirstLine("ZZZ;aaa;XXX");

            firstLineElements.ShouldBe(null);
        }
예제 #19
0
        public void return_minus_1_when_second_line_is_read_and_the_number_is_not_an_integer()
        {
            int nbrExchangeRates = ConsoleParser.ReadSecondLine("a");

            nbrExchangeRates.ShouldBe(-1);
        }
예제 #20
0
 public void SetParser(ConsoleParser cp_)
 {
     consoleParser = cp_;
 }
예제 #21
0
        public void return_null_when_third_line_is_read_does_not_contain_3_elements()
        {
            Tuple <string, string, decimal> exchangeRateLineElements = ConsoleParser.ReadExchangeRatesLine("AUD;CHF");

            exchangeRateLineElements.ShouldBe(null);
        }
예제 #22
0
 private void saveMidi(string abcpath, string midipath)
 {
     string a = ConsoleParser.ExecuteCommand(StringConstants.ABC2MIDI, "\"" + abcpath + "\" -o \"" + midipath + "\"");
 }