public void ParseRobotMoves() { CommandsParser commandParser = new CommandsParser(); var result = commandParser.ParseRobotMoves("LMLMLMLMM"); Assert.IsTrue(result.Count > 0); }
public void MoveRobotToPosition() { CommandsParser commandParser = new CommandsParser(); Arena arena; bool result = commandParser.IsValidArenaCommand("5 5", out arena); Assert.IsTrue(result); Robot robot; result = commandParser.IsValidCreateRobotCommand("1 2 N", out robot); Assert.IsTrue(result); var moves = commandParser.ParseRobotMoves("LMLMLMLMM"); Assert.IsTrue(moves.Count > 0); MovesProvider provider = new MovesProvider(); provider.MoveRobotToPosition(arena, robot, moves); Assert.AreEqual <int>(1, robot.PositionX); Assert.AreEqual <int>(3, robot.PositionY); Assert.AreEqual <CompasPoints>(CompasPoints.North, robot.Compas); }
public void IsValidCreateRobotCommandTest() { CommandsParser commandParser = new CommandsParser(); Robot robot; bool result = commandParser.IsValidCreateRobotCommand("1 2 N", out robot); Assert.IsTrue(result); }
public void IsValidArenaCommandTest() { CommandsParser commandParser = new CommandsParser(); Arena arena; bool result = commandParser.IsValidArenaCommand("5 5", out arena); Assert.IsTrue(result); }
internal new static void Main(string[] args) { ShowLogo(); var parser = new CommandsParser <CommandLineOptions>(); Console.WriteLine(parser.Usage); Exit(0); }
public void OpenCommandsFile_ThrowsWhenCommandsDontExist() { var fileSys = new MockFileSystem(); var parser = new CommandsParser(fileSys); Assert.Throws <FileNotFoundException>(() => parser.OpenCommandsFile(null)); Assert.Throws <FileNotFoundException>(() => parser.OpenCommandsFile(new string[0])); Assert.Throws <FileNotFoundException>(() => parser.OpenCommandsFile(new [] { @"x:\non_existent+path\" })); Assert.Throws <FileNotFoundException>(() => parser.OpenCommandsFile(new [] { @"x:\non_existent_path\commands.jsom" })); }
public void OpenCommandsFile_FileFoundViaArgsExplicit() { var fileSys = new MockFileSystem(new Dictionary <string, MockFileData>() { { @"x:\path\cmd.json", new MockFileData("{}") } }); var parser = new CommandsParser(fileSys); Assert.DoesNotThrow(() => parser.OpenCommandsFile(new [] { @"x:\path\cmd.json" })); Assert.NotNull(parser.CommandFile); Assert.AreEqual("cmd.json", parser.CommandFile.Name); }
private static void ParseArgs(string[] args) { var parser = new CommandsParser <CommandLineOptions>(); var result = parser.Parse(args); if (!result.Success) { foreach (var error in result.Errors) { Logger.Error(error); } Exit(-1); } CommandLineOptions.Global = result.Options; }
private static Command ReceivePacket(UdpClient udpServer, IPEndPoint remoteEp) { try { var received = udpServer.Receive(ref remoteEp); var command = CommandsParser.ParseCommand(received); return(command); } catch (SocketException) { return(new NoResponseCommand() { CommandType = BlockchainCommands.NO_RESPONSE }); } }
static void Main(string[] args) { CommandsParser commandParser = new CommandsParser(); Console.WriteLine("Enter coordinates of the Arena"); string arenaCommands = Console.ReadLine(); Arena arena = null; if (!commandParser.IsValidArenaCommand(arenaCommands, out arena)) { Console.WriteLine("Invalid command"); Console.ReadKey(); return; } while (true) { Console.WriteLine("Enter position for robot"); string commands = Console.ReadLine(); Robot robot = null; if (!commandParser.IsValidCreateRobotCommand(commands, out robot)) { Console.WriteLine("Invalid command"); Console.ReadKey(); return; } if (robot.PositionX > arena.Width || robot.PositionY > arena.Hight) { Console.WriteLine("Invalid coordinates"); Console.ReadKey(); return; } Console.WriteLine("Enter robot moves"); commands = Console.ReadLine(); var moves = commandParser.ParseRobotMoves(commands); var movesProvider = new MovesProvider(); movesProvider.MoveRobotToPosition(arena, robot, moves); Console.WriteLine("{0} {1} {2}", robot.PositionX, robot.PositionY, robot.Compas); } }
private SpreadsheetInstance(string spreadsheetId, string databaseSheet, string databaseFamilyNamesColumn, int databaseHeadersRow, string partiesSheet, int partiesHeadersRow) { UserCredential credential; using (var stream = new FileStream("client_secret.json", FileMode.Open, FileAccess.Read)) { string credPath = Environment.GetFolderPath( Environment.SpecialFolder.Personal); credPath = Path.Combine(credPath, ".credentials/sheets.googleapis.com-dotnet-quickstart.json"); credential = GoogleWebAuthorizationBroker.AuthorizeAsync( GoogleClientSecrets.Load(stream).Secrets, Scopes, "user", CancellationToken.None, new FileDataStore(credPath, true)).Result; Console.WriteLine("Credential file saved to: " + credPath); } // Create Google Sheets API service. Service = new SheetsService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = ApplicationName, }); Spreadsheet = new Models.Spreadsheet(spreadsheetId) { DatabaseSheet = new DatabaseSheet(databaseSheet), PartiesSheet = new DatabaseSheet(partiesSheet) }; SupportMethods = new SupportMethods(Service, Spreadsheet); PopulateSpreadsheetModel(databaseFamilyNamesColumn, databaseHeadersRow, partiesHeadersRow); CommandsParser = new CommandsParser(Service, Spreadsheet, SupportMethods); ReactionsParser = new ReactionsParser(Service, Spreadsheet, SupportMethods); }
public Help(CommandsParser parser) { ParentParser = parser; }
static async Task Main(string[] args) { Console.OutputEncoding = System.Text.Encoding.UTF8; CommandsParser commandParser = new CommandsParser(); IFeedService feedService = new FeedService(); _feedRepository = new FeedXmlRepository(); string[] arrString; //_feedRepository.Create(new Feed() { Name = "news", Url = "https://www.liga.net/news/rss.xml" }); //_feedRepository.Create(new Feed() { Name = "articles", Url = "https://www.liga.net/news/articles/rss.xml" }); //_feedRepository.Create(new Feed() { Name = "interview", Url = "https://www.liga.net/news/interview/rss.xml" }); //_feedRepository.Create(new Feed() { Name = "opinion", Url = "https://www.liga.net/opinion/rss.xml" }); //_feedRepository.Create(new Feed() { Name = "crypto", Url = "https://www.liga.net/fin/crypto/rss.xml" }); //_feedRepository.Create(new Feed() { Name = "blog", Url = "https://www.liga.net/rss/blog.xml" }); //_feedRepository.Create(new Feed() { Name = "vlog", Url = "https://www.liga.net/tech/vlog/rss.xml" }); //_feedRepository.Create(new Feed() { Name = "news2.0", Url = "https://www.liga.net/news/rss.xml" }); //var result = _feedRepository.GetAll(); //var res = _feedRepository.GetByName("news2.0"); //_feedRepository.Delete("news2.0"); while (true) { do { Console.Write("Enter the command->"); }while (!commandParser.TryParse(Console.ReadLine(), out arrString)); try { switch (arrString[0].ToLower()) { case "add": _feedRepository.Create(new Feed { Name = arrString[1], Url = arrString[2] }); Console.WriteLine("Feed added"); break; case "remove": _feedRepository.Delete(arrString[1]); Console.WriteLine("Feed removed"); break; case "download": var feeds = _feedRepository.GetAll(); if (feeds.Count == 0) { Console.WriteLine("XML-file with feeds is empty"); continue; } IList <string> names = new List <string>(); for (int i = 1; i < arrString.Length; i++) { if (feeds.Where(x => x.Name == arrString[i]).Count() > 0) { names.Add(feeds.Where(x => x.Name == arrString[i]).Select(x => x.Url).FirstOrDefault()); } } if (names.Count < 1) { Console.WriteLine("Nothing was found"); continue; } await feedService.Run(names.ToArray()); break; } } catch (Exception e) { Console.WriteLine(e); } } //var feeds = _feedRepository.GetAll(); //string[] urls = feeds.Select(f => f.Url).ToArray(); //await feedService.Run(urls); }
public void SetUp() { _parser = new CommandsParser <CommandLineOptions>(); }
public SetWordsScale(CommandsParser parser) { ParentParser = parser; }
public SetBoringWords(CommandsParser parser) { ParentParser = parser; }
private void ParseProgram(string programText) { commands = CommandsParser.Parse(programText); }
public SetDensityFlag(CommandsParser parser) { ParentParser = parser; }
public SetSize(CommandsParser parser) { ParentParser = parser; }
public SetFontFamily(CommandsParser parser) { ParentParser = parser; }
public static void Main(string[] args) { Console.WriteLine("Welcome to Martian Researching System!"); Console.WriteLine("Please, type your input and press TAB when complete"); var userInput = new StringBuilder(); do { var line = Console.ReadLine(); if (!line.IsNullOrWhiteSpace()) { userInput.AppendLine(line); } }while (Console.ReadKey(true).Key != ConsoleKey.Tab); var lines = userInput .ToString() .Split(new string[] { Environment.NewLine }, StringSplitOptions.None); Console.WriteLine(); Console.Write("Creating Mars Surface..."); var marsSurfaceDataParser = new MarsSurfaceDataParser(); var marsSurface = marsSurfaceDataParser.ParseMarsSurface(lines.First()); Console.WriteLine("OK"); Console.WriteLine(); Console.WriteLine("Deploying robots..."); var robotDataParser = new RobotDataParser(); var commandsParser = new CommandsParser(); var thingsToDo = new Dictionary <SimpleMartianRobot, List <Command> >(); for (var i = 1; i < lines.Length - 1; i += 2) { var newRobot = robotDataParser.ParseRobotData(lines[i]); var commandsForRobot = commandsParser.ParseCommandString(lines[i + 1]); thingsToDo.Add(newRobot, commandsForRobot); Console.WriteLine($"Robot {newRobot.Id} deployed!"); } Console.WriteLine(); Console.WriteLine("Starting Reseacrch Session..."); var researchSession = new ResearchSession { MarsSurface = marsSurface, Operands = thingsToDo }; researchSession.Execute(); foreach (var robot in researchSession.Operands.Keys) { Console.WriteLine(robot); } Console.ReadLine(); }
/// <summary> /// Пропарсить текст скрипта. /// </summary> public Script parseScript(string page) { return(CommandsParser.parseScript(page)); }
public SetWordsColors(CommandsParser parser) { ParentParser = parser; }
public static State ProcessReceiveRequest(State state, byte[] messageBytes, NodeDetails node) { var command = CommandsParser.ParseCommand(messageBytes); return(ProcessReceiveRequest(state, command, node)); }