public void ShouldHaveTwoParameters() { var parameters = new[] {"-c", @"C:\RootDir"}; var parser = new InputParser(parameters); Assert.AreEqual(2, parser.Parameters.Count); }
public void ShouldHaveThreeParameters() { var parameters = new[] {"-c", @"C:\RootDir", @"C:\Shortcuts"}; var parser = new InputParser(parameters); Assert.AreEqual(3, parser.Parameters.Count); }
public void ParseLawnMowerCommands_ShouldThrowWhenInputIsInvalid( string input) { var inputParser = new InputParser(); Action call = () => inputParser.ParseLawnMowerCommands(input).ToArray(); call.ShouldThrow<InvalidInputException>(); }
public void ParseCommand_InvalidCommandFormat() { var inputParser = new InputParser(); string[] rawInput = "UP".Split(' '); var exception = Assert.Throws<ArgumentException>(delegate { inputParser.ParseCommand(rawInput); }); Assert.That(exception.Message, Is.EqualTo("Invalid Command. Please select from one of the following command: PLACE X,Y,F|MOVE|LEFT|RIGHT|REPORT")); }
public void ParseCommand_validCommandFormat() { var inputParser = new InputParser(); string[] rawInput = "PLACE".Split(' '); var command = inputParser.ParseCommand(rawInput); Assert.AreEqual(Command.Place, command); }
public void ShouldAcceptDirectoryWithSpace() { var parameters = new[] {"-u", @"C:\Root Dir", @"C:\Shortcut"}; var parser = new InputParser(parameters); Assert.AreEqual("-u", parser.Parameters[ParameterName.Operation]); Assert.AreEqual(@"C:\Root Dir", parser.Parameters[ParameterName.RootDir]); Assert.AreEqual(@"C:\Shortcut", parser.Parameters[ParameterName.ShortcutDir]); }
public void ShouldMapParametersCorrectly() { var parameters = new[] { "-u", @"C:\RootDir", @"C:\Shortcuts" }; var parser = new InputParser(parameters); Assert.AreEqual("-u", parser.Parameters[ParameterName.Operation]); Assert.AreEqual(@"C:\RootDir", parser.Parameters[ParameterName.RootDir]); Assert.AreEqual(@"C:\Shortcuts", parser.Parameters[ParameterName.ShortcutDir]); }
public void TestProcessCommand_InvalidRobotPlacement() { ISquareBoard squareBoard = new SquareBoard(5, 5); IInputParser inputParser = new InputParser(); IToyRobot robot = new ToyRobot(); var simulator = new Simulator.Simulator(robot, squareBoard, inputParser); simulator.ProcessCommand("PLACE 6,6,EAST".Split(' ')); Assert.IsNull(robot.Position); }
public void TestParseCommandParameter_ValidPlaceCommandParamFormat() { var inputParser = new InputParser(); string[] rawInput = "PLACE 1,2,EAST".Split(' '); var placeCommandParameter = inputParser.ParseCommandParameter<PlaceCommandParameter>(new PlaceCommandParameterParser(), rawInput); Assert.AreEqual(1, placeCommandParameter.Position.X); Assert.AreEqual(2, placeCommandParameter.Position.Y); Assert.AreEqual(Direction.East, placeCommandParameter.Direction); }
public void TestParseCommandParameter_IncompletePlaceCommandParamFormat() { var inputParser = new InputParser(); string[] rawInput = "PLACE 1,2".Split(' '); var exception = Assert.Throws<ArgumentException>(delegate { inputParser.ParseCommandParameter<PlaceCommandParameter>(new PlaceCommandParameterParser(), rawInput); }); Assert.That(exception.Message, Is.EqualTo("Incomplete command. Please ensure that the PLACE command is using format: PLACE X,Y,F")); }
public void TestProcessCommand_MoveToyRobot() { ISquareBoard squareBoard = new SquareBoard(5, 5); IInputParser inputParser = new InputParser(); IToyRobot robot = new ToyRobot(); var simulator = new Simulator.Simulator(robot, squareBoard, inputParser); simulator.ProcessCommand("PLACE 0,0,NORTH".Split(' ')); simulator.ProcessCommand("MOVE".Split(' ')); Assert.AreEqual("Output: 0,1,NORTH", simulator.GetReport()); }
public void TestProcessCommand_PlaceToyRobot() { ISquareBoard squareBoard = new SquareBoard(5, 5); IInputParser inputParser = new InputParser(); IToyRobot robot = new ToyRobot(); var simulator = new Simulator.Simulator(robot, squareBoard, inputParser); simulator.ProcessCommand("PLACE 1,2,EAST".Split(' ')); Assert.AreEqual(1, robot.Position.X); Assert.AreEqual(2, robot.Position.Y); Assert.AreEqual(Direction.East, robot.Direction); }
private static void parseInputSeparately(InputParser inputParser, out int serverNO, out int pointNO, out double delta, out int spaceDimension, out int histogramResolution, out Array array) { inputParser.parseInputSizes(out spaceDimension, out histogramResolution, out serverNO); Console.WriteLine("Space dim: {0}, resolution: {1}, server no.: {2}", spaceDimension, histogramResolution, serverNO); int[] lengthsArray = new int[spaceDimension]; for (int idx = 0; idx < spaceDimension; idx++) { lengthsArray[idx] = histogramResolution; } array = Array.CreateInstance(typeof(int), lengthsArray); inputParser.parseInputArray(serverNO, histogramResolution, array, out pointNO, out delta); }
public static void Main(string[] args) { const string description = @"Hello and Welcome to the Toy Robot simulator! 1: Start of by placing the robot on a square grid with dimensions of 5 X 5. Use the following command to place the robot. PLACE X,Y, F (F = NORTH SOUTH EAST or WEST) 2: Once the robot is placed, interact with it using the following commands. MOVE – Moves the robot 1 unit to the direction it is facing. LEFT – Rotates the robot to 90 degrees in the left direction. RIGHT – Rotates the robot 90 degrees in the right direction. REPORT – Queries the current stats of the robot. EXIT – Close Toy Robot Simulator. "; ISquareBoard squareBoard = new SquareBoard(5, 5); IInputParser inputParser = new InputParser(); IToyRobot robot = new ToyRobot(); var simulator = new Simulator.Simulator(robot, squareBoard, inputParser); var stopApplication = false; Console.WriteLine(description); do { var command = Console.ReadLine(); if (command == null) continue; if (command.Equals("EXIT")) stopApplication = true; else { try { var output = simulator.ProcessCommand(command.Split(' ')); if (!string.IsNullOrEmpty(output)) Console.WriteLine(output); } catch (ArgumentException exception) { Console.WriteLine(exception.Message); } } } while (!stopApplication); }
private static void Execute(string[] args) { try { var parser = new InputParser(args); if (parser.Parameters[ParameterName.Operation].Equals("-c")) CreateShortcuts(parser.Parameters); else if (parser.Parameters[ParameterName.Operation].Equals("-u")) UpdateSvnDirectories(parser.Parameters); } catch (Exception e) { Console.WriteLine(e.Message); } }
private static void lpProblemPhase(InputParser inputParser, int serverNO, int pointNO, double delta, int binNO, int[] binHefts, double explicitLimit, LPModelFileCreator lpModelFileCreator, LPSolver lpSolver) { int timeoutSec = inputParser.parseInputTimeout(); bool deleteOutputLP = inputParser.parseInputDeleteOutputLP(); string outputFilename = lpModelFileCreator.createOutputLPFile(serverNO, binNO, pointNO, binHefts, delta, explicitLimit); lpSolver.solveLP(serverNO, binNO, binHefts, timeoutSec, outputFilename); if (deleteOutputLP) { File.Delete(outputFilename); } }
public void TestProcessCommand_TryDestroyToyRobot() { ISquareBoard squareBoard = new SquareBoard(5, 5); IInputParser inputParser = new InputParser(); IToyRobot robot = new ToyRobot(); var simulator = new Simulator.Simulator(robot, squareBoard, inputParser); simulator.ProcessCommand("PLACE 0,0,NORTH".Split(' ')); simulator.ProcessCommand("MOVE".Split(' ')); simulator.ProcessCommand("LEFT".Split(' ')); // if the robot goes out of the board it ignores the command simulator.ProcessCommand("MOVE".Split(' ')); Assert.AreEqual("Output: 0,1,WEST", simulator.GetReport()); }
public void ParseLawnMowerState_ShouldReturnCorrectStateWhenInputIsValid( string input, int expectedX, int expectedY, char expectedDirectionSign) { var inputParser = new InputParser(); var parsedState = inputParser.ParseLawnMowerState(input); var expectedState = new LawnMowerState( new Position(expectedX, expectedY), Direction.GetBySign(expectedDirectionSign)); parsedState .Should() .Be(expectedState); }
public void ParseLawnMowerCommands_ShouldReturnCorrectCommandsWhenInputIsValid() { var inputParser = new InputParser(); var parsedCommands = inputParser.ParseLawnMowerCommands("MLRRRLLM"); var expectedCommands = new[] { LawnMowerCommand.MoveForward, LawnMowerCommand.TurnLeft, LawnMowerCommand.TurnRight, LawnMowerCommand.TurnRight, LawnMowerCommand.TurnRight, LawnMowerCommand.TurnLeft, LawnMowerCommand.TurnLeft, LawnMowerCommand.MoveForward, }; parsedCommands .Should() .Equal(expectedCommands); }
private static void binCreationPhase(InputParser inputParser, BinsCreator binsCreator, out int serverNO, out int pointNO, out double delta, out int spaceDimension, out int histogramResolution, out Array array, out int[] binHefts, out int binNO, out double explicitLimit) { explicitLimit = inputParser.determineExplicitOrImplicitLimit(); bool together = inputParser.determineTogetherOrSeparately(); if (together) { array = inputParser.parseInputFile(out spaceDimension, out histogramResolution, out serverNO, out pointNO, out delta); } else { parseInputSeparately(inputParser, out serverNO, out pointNO, out delta, out spaceDimension, out histogramResolution, out array); } Console.WriteLine("Point no.: {0}", pointNO); Console.WriteLine("Delta: {0}", delta); Bin[] bins = binsCreator.createBinsFromHistogram(spaceDimension, histogramResolution, array); binNO = (int)Math.Pow(histogramResolution, spaceDimension); binHefts = writeOutBins(spaceDimension, binNO, bins); }
static void Main(string[] args) { // IMPORTANT NOTE: // please check the Debug or Release folder contains lpsolve55.dll and build on x86 platform. IndexTransformator transformator = new IndexTransformator(); InputParser inputParser = new InputParser(transformator); BinsCreator binsCreator = new BinsCreator(transformator); LPModelFileCreator lpModelFileCreator = new LPModelFileCreator(); LPSolver lpSolver = new LPSolver(); int serverNO; int pointNO; double delta; int spaceDimension; int histogramResolution; Array array; int[] binHefts; int binNO; double explicitLimit; binCreationPhase(inputParser, binsCreator, out serverNO, out pointNO, out delta, out spaceDimension, out histogramResolution, out array, out binHefts, out binNO, out explicitLimit); lpProblemPhase(inputParser, serverNO, pointNO, delta, binNO, binHefts, explicitLimit, lpModelFileCreator, lpSolver); Console.WriteLine("Press any key to exit!"); Console.Read(); }
public static void main123(string[] args) { TraceSource log = new TraceSource(typeof(EPATool).FullName, SourceLevels.All); string hydFile = null; string qualFile = null; var net = new EpanetNetwork(); List <NodeVariableType> nodesVariables = new List <NodeVariableType>(); List <LinkVariableType> linksVariables = new List <LinkVariableType>(); string inFile = ""; List <long> targetTimes = new List <long>(); List <string> targetNodes = new List <string>(); List <string> targetLinks = new List <string>(); int parseMode = 0; foreach (string arg in args) { if (arg.EndsWith(".inp", StringComparison.OrdinalIgnoreCase)) { parseMode = 0; inFile = arg; if (!File.Exists(inFile)) { ConsoleLog("END_RUN_ERR"); Console.Error.WriteLine("File not found !"); return; } continue; } switch (arg) { case "-T": case "-t": parseMode = 1; continue; case "-N": case "-n": parseMode = 2; continue; case "-L": case "-l": parseMode = 3; continue; } switch (parseMode) { case 1: targetTimes.Add((long)(Utilities.GetHour(arg) * 3600)); break; case 2: targetNodes.Add(arg); break; case 3: targetLinks.Add(arg); break; } } try { InputParser parserInp = InputParser.Create(FileType.INP_FILE); net = parserInp.Parse(new EpanetNetwork(), inFile); if (targetTimes.Count > 0) { foreach (long time in targetTimes) { string epanetTime = time.GetClockTime(); if (time < net.RStart) { throw new Exception("Target time \"" + epanetTime + "\" smaller than simulation start time"); } if (time > net.Duration) { throw new Exception("Target time \"" + epanetTime + "\" bigger than simulation duration"); } if ((time - net.RStart) % net.RStep != 0) { throw new Exception("Target time \"" + epanetTime + "\" not found"); } } } foreach (string nodeName in targetNodes) { if (net.GetNode(nodeName) == null) { throw new Exception("Node \"" + nodeName + "\" not found"); } } foreach (string linkName in targetLinks) { if (net.GetLink(linkName) == null) { throw new Exception("Link \"" + linkName + "\" not found"); } } nodesVariables.Add(NodeVariableType.ELEVATION); nodesVariables.Add(NodeVariableType.BASEDEMAND); if (net.QualFlag != QualType.NONE) { nodesVariables.Add(NodeVariableType.INITQUALITY); } nodesVariables.Add(NodeVariableType.PRESSURE); nodesVariables.Add(NodeVariableType.HEAD); nodesVariables.Add(NodeVariableType.DEMAND); if (net.QualFlag != (QualType.NONE)) { nodesVariables.Add(NodeVariableType.QUALITY); } linksVariables.Add(LinkVariableType.LENGHT); linksVariables.Add(LinkVariableType.DIAMETER); linksVariables.Add(LinkVariableType.ROUGHNESS); linksVariables.Add(LinkVariableType.FLOW); linksVariables.Add(LinkVariableType.VELOCITY); linksVariables.Add(LinkVariableType.UNITHEADLOSS); linksVariables.Add(LinkVariableType.FRICTIONFACTOR); if (net.QualFlag != QualType.NONE) { linksVariables.Add(LinkVariableType.QUALITY); } hydFile = Path.GetTempFileName(); // "hydSim.bin" ConsoleLog("START_RUNNING"); HydraulicSim hydSim = new HydraulicSim(net, log); hydSim.Simulate(hydFile); if (net.QualFlag != QualType.NONE) { qualFile = Path.GetTempFileName(); // "qualSim.bin" QualitySim q = new QualitySim(net, log); q.Simulate(hydFile, qualFile); } HydraulicReader hydReader = new HydraulicReader(new BinaryReader(File.OpenRead(hydFile))); StreamWriter nodesTextWriter = null; StreamWriter linksTextWriter = null; string nodesOutputFile = null; if (targetNodes.Count == 0 && targetLinks.Count == 0 || targetNodes.Count > 0) { nodesOutputFile = Path.GetFullPath(inFile) + ".nodes.out"; nodesTextWriter = new StreamWriter(nodesOutputFile, false, Encoding.UTF8); nodesTextWriter.Write('\t'); foreach (NodeVariableType nodeVar in nodesVariables) { nodesTextWriter.Write('\t'); nodesTextWriter.Write(nodeVar.ToString()); } nodesTextWriter.Write("\n\t"); foreach (NodeVariableType nodeVar in nodesVariables) { nodesTextWriter.Write('\t'); nodesTextWriter.Write(net.FieldsMap.GetField(ToFieldType(nodeVar)).Units); } nodesTextWriter.Write('\n'); } if (targetNodes.Count == 0 && targetLinks.Count == 0 || targetLinks.Count > 0) { string linksOutputFile = Path.GetFullPath(inFile) + ".links.out"; linksTextWriter = new StreamWriter(linksOutputFile, false, Encoding.UTF8); linksTextWriter.Write('\t'); foreach (LinkVariableType linkVar in linksVariables) { linksTextWriter.Write('\t'); linksTextWriter.Write(linkVar.ToString()); } linksTextWriter.Write("\n\t"); foreach (LinkVariableType linkVar in linksVariables) { linksTextWriter.Write('\t'); if (linkVar < 0) { continue; } linksTextWriter.Write(net.FieldsMap.GetField((FieldType)linkVar).Units); } linksTextWriter.Write('\n'); } for (long time = net.RStart; time <= net.Duration; time += net.RStep) { AwareStep step = hydReader.GetStep((int)time); int i = 0; if (targetTimes.Count > 0 && !targetTimes.Contains(time)) { continue; } if (nodesTextWriter != null) { foreach (Node node in net.Nodes) { if (targetNodes.Count > 0 && !targetNodes.Contains(node.Name)) { continue; } nodesTextWriter.Write(node.Name); nodesTextWriter.Write('\t'); nodesTextWriter.Write(time.GetClockTime()); foreach (NodeVariableType nodeVar in nodesVariables) { nodesTextWriter.Write('\t'); double val = GetNodeValue(nodeVar, net.FieldsMap, step, node, i); nodesTextWriter.Write(ConvertToScientifcNotation(val, 1000, 0.01, 2)); } nodesTextWriter.Write('\n'); i++; } } i = 0; if (linksTextWriter != null) { foreach (Link link in net.Links) { if (targetLinks.Count > 0 && !targetLinks.Contains(link.Name)) { continue; } linksTextWriter.Write(link.Name); linksTextWriter.Write('\t'); linksTextWriter.Write(time.GetClockTime()); foreach (LinkVariableType linkVar in linksVariables) { linksTextWriter.Write('\t'); double val = GetLinkValue( linkVar, net.FormFlag, net.FieldsMap, step, link, i); linksTextWriter.Write(ConvertToScientifcNotation(val, 1000, 0.01, 2)); } linksTextWriter.Write('\n'); i++; } } } if (nodesTextWriter != null) { nodesTextWriter.Close(); ConsoleLog("NODES FILE \"" + nodesOutputFile + "\""); } if (linksTextWriter != null) { linksTextWriter.Close(); ConsoleLog("LINKS FILES \"" + nodesOutputFile + "\""); } ConsoleLog("END_RUN_OK"); } catch (ENException e) { ConsoleLog("END_RUN_ERR"); Debug.Print(e.ToString()); } catch (IOException e) { ConsoleLog("END_RUN_ERR"); Debug.Print(e.ToString()); } catch (Exception e) { ConsoleLog("END_RUN_ERR"); Debug.Print(e.ToString()); } if (!string.IsNullOrEmpty(hydFile)) { File.Delete(hydFile); } if (!string.IsNullOrEmpty(qualFile)) { File.Delete(qualFile); } }
public MongoDbStringNotEndsWithHandler(InputParser inputParser) : base(inputParser) { CanBeNull = false; }
public void ParseData_NullData_ThrowsException() { InputParser.Parse(null as byte[]); }
public void ParseLawnSize_ShouldReturnCorrectLawnSizeWhenInputIsValid( string input, int expectedTopmostCoordinate, int expectedRightmostCoordinate) { var inputParser = new InputParser(); var lawnSize = inputParser.ParseLawnSize(input); var expectedLawnSize = new LawnSize( expectedRightmostCoordinate, expectedTopmostCoordinate); lawnSize .Should() .Be(expectedLawnSize); }
/// <summary> /// Erstellt eine Fünf-Punkte-Zusammenfassung für die übergebene Liste an Zahlen. /// </summary> /// <param name="arrValues">Eine Liste mit String-Werten, die Zahlen abbilden.</param> /// <returns>Die erstellte Fünf-Punkte-Zusammenfassung</returns> public static FivePointSummary Get(string[] arrValues) { return(Get(InputParser.ParseDoubleList(arrValues))); }
static void Main(string[] args) { /************ Create node object ************/ RegisterType type = RegisterType.ComputationalNode; byte parallelThreads = 5; string[] problems = { "DVRP" }; NetworkNode node = new NetworkNode(type, parallelThreads, problems); //NetworkNode node = new NetworkNode(); /************ Setup connection ************/ string inputLine = ""; foreach (string arg in args) { inputLine += arg + " "; } InputParser inputParser = new InputParser(inputLine); inputParser.ParseInput(); IPAddress address = inputParser.Address; int port = inputParser.Port; SmartConsole.PrintLine("I'm a " + node.Type, SmartConsole.DebugLevel.Advanced); NetworkClient client = new NetworkClient(address, port); /************ Setup Logic modules ************/ // system tracker SystemTracker systemTracker = new SystemTracker(node); MessageHandler messageHandler = new MessageHandler(systemTracker, client); MessageProcessor messageProcessor = new MessageProcessor(messageHandler, client, node); node.MessageProcessor = messageProcessor; /************ Init all threads ************/ for (int i = 0; i < parallelThreads; i++) { node.TaskThreads[i] = new TaskThread(i, problems[0], messageProcessor, (int)node.Id); } /************ Register ************/ client.Connect(); SmartConsole.PrintLine("Sending Register message", SmartConsole.DebugLevel.Advanced); messageProcessor.Communicate(node.ToRegisterMessage()); KeepAliveTimer keepAliveTimer = new KeepAliveTimer(messageProcessor, systemTracker); /************ Start Logic modules ************/ keepAliveTimer.Start(); Object mutex = new Object(); //for (; ; ) ; // TODO Thread pool waiting lock (mutex) { Monitor.Wait(mutex); } }
public void InputParser_ParseStringWithBackReference(string testString, int expected) { var result = new InputParser().ParseInputString(testString, UriMatchPart.Path); Assert.Equal(expected, result.PatternSegments.Count); }
public NotEndsWithHandler(InputParser inputParser) : base(inputParser) { }
public void ViewMovieList(User user) { List <Movie> movies = new List <Movie>(); bool isFinished = false; string errorMessage = string.Empty; while (!isFinished) { Screen.ClearScreen(); if (!string.IsNullOrWhiteSpace(errorMessage)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(errorMessage); Console.ResetColor(); errorMessage = string.Empty; } if (movies.Count != 0) { movies.PrintMovies(); } Screen.OrderingMenu(); var selection = InputParser.ToInteger(0, 9); switch (selection) { case 1: movies = _movieRepository.GetAll(); break; case 2: movies = _movieRepository.OrderByGenre(true); break; case 3: Genre genre = InputParser.ToGenre(); movies = _movieRepository.Filter(x => x.Genre == genre); break; case 4: movies = _movieRepository.OrderByReleaseDate(true); break; case 5: int year = InputParser.ToInteger( _movieRepository.GetAll().Min(_movie => _movie.ReleaseDate.Year), DateTime.Now.Year - 1 ); movies = _movieRepository.Filter(x => x.ReleaseDate.Year == year); break; case 6: movies = _movieRepository.OrderByAvailability(true); break; case 7: movies = _movieRepository.Filter(x => x.IsAvailable); break; case 8: string titlePart = Console.ReadLine(); string trimedTitlePart = titlePart.Trim().ToLower(); movies = _movieRepository.Filter(x => x.Title.ToLower().Contains(trimedTitlePart)); break; case 9: //TODO: Rent a movie try { RentMovie(user); } catch (Exception ex) { // TODO: Find a way to show error message. errorMessage = ex.Message; } break; case 0: isFinished = !isFinished; break; } } }
public FormatConverter(IDocumentSerializer documentSerializer, InputParser inputParser) { _documentSerializer = documentSerializer; _inputParser = inputParser; }
public Neo4JNotInOperationHandler(InputParser inputParser) : base(inputParser) { }
public void ParseStream_NullData_ThrowsException() { InputParser.Parse(null as Stream); }
public UriMatchCondition(InputParser inputParser, string input, string pattern, UriMatchPart uriMatchPart, bool ignoreCase, bool negate) : base(CreatePattern(inputParser, input, uriMatchPart), CreateRegexMatch(pattern, ignoreCase, negate)) { }
private static Pattern CreatePattern(InputParser inputParser, string input, UriMatchPart uriMatchPart) { return(inputParser.ParseInputString(input, uriMatchPart)); }
/// <summary> /// Erstellt eine Fünf-Punkte-Zusammenfassung für die übergebene Liste an Zahlen. /// </summary> /// <param name="strValues">Eine Liste mit String-Werten, die Zahlen abbilden.</param> /// <param name="cDivider">Das Zeichen, mit dem einzelne Werte voneinander getrennt sind.</param> /// <returns></returns> public static FivePointSummary Get(string strValues, char cDivider = ';') { return(Get(InputParser.ParseDoubleList(strValues, cDivider))); }
public QueryableEnumInHandler( ITypeConverter typeConverter, InputParser inputParser) : base(typeConverter, inputParser) { }
/// <summary> /// Assign the global singleton, or disables if one is already found /// Also intialize any necessary internal variables /// </summary> void Awake() { if(InputParser.instance == null) { instance = this; } else { Debug.LogWarning("Multiple instance of InputParser singleton found, disabling this one : " + this.gameObject.name.ToString()); this.enabled = false; } if(raycast_Cameras.Count == 0) { Debug.LogWarning("There are no cameras assigned to raycast from the InputParser, disabling this : " + this.gameObject.name.ToString()); this.enabled = false; } if(LayersForInput == _layerSet_Nothing) { Debug.LogWarning("InputParser - no layers assigned for input : This is not an issue if you intend to assign new LayerMask objects to the InputParser's public mask object 'LayersForInput' during runtime."); Debug.LogWarning("InputParser - no layers assigned for input : Currently no renderers are going to be raycasted or sent input messages!"); } //Clicks should never be delayed by this script for flow of control purposes, only enough to properly process inputs _time_ClickUnDelayed = Time.time; //Store screen dimensions so we can easily tell if the mouse is in the screen or not _screenW = Screen.width; _screenH = Screen.height; //Flag if we are on mobile or not so that we don't have to use preprocessor directives in the rest of the code #if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBPLAYER || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN _useMouse = true; //If this is built to use mouse, we will add a single internalInputTracker to our list so that we don't have to worry about it later //There will only ever be this one tracker in the List (for the mouse); the List remains because it makes the code uniform in FixedUpdate() when // sending messages, eliminating the need to handle them differently in FixedUpdate() _ongoing_Inputs.Add(new internalInputTracker(Vector3.zero)); #else _useMouse = false; _ongoing_Inputs.Clear(); //Initialize the removal list for touches _queuedRemoval_Inputs = new List<internalInputTracker>(); _queuedRemoval_Inputs.Clear(); #endif }
protected void when_parsing(string input) { Result = InputParser.Parse(input); }
protected QueryableOperationHandlerBase(InputParser inputParser) { InputParser = inputParser; }
public void ParseLawnMowerState_ShouldThrowWhenInputIsInvalid( string input) { var inputParser = new InputParser(); Action call = () => inputParser.ParseLawnMowerState(input); call.ShouldThrow<InvalidInputException>(); }
public QueryableComparableEqualsHandler( ITypeConverter typeConverter, InputParser inputParser) : base(typeConverter, inputParser) { }
public AnalyseControllerService(dynamic parameters) { _inputParser = new InputParser(parameters); }
public string SolveOneCase(InputParser input) { R = input.GetInt(); C = input.GetInt(); str = new string[R]; for (int i = 0; i < R; i++) { str[i] = input.GetString(); } count = 0; for (int i = 0; i < R; i++) { for (int j = 0; j < C; j++) { var c = str[i][j]; bool t = navigate(i, j, true, c); if (!t) { if (c != '<') { var x = navigate(i, j, true, '<'); if (x) { count++; continue; } } if (c != '^') { var x = navigate(i, j, true, '^'); if (x) { count++; continue; } } if (c != '>') { var x = navigate(i, j, true, '>'); if (x) { count++; continue; } } if (c != 'v') { var x = navigate(i, j, true, 'v'); if (x) { count++; continue; } } return(IMP); } } } return(count.ToString()); }
public void ParseData_EmptyData_ThrowsException() { InputParser.Parse(new byte[0]); }
public void TestProcessCommand_ReportCommand() { ISquareBoard squareBoard = new SquareBoard(5, 5); IInputParser inputParser = new InputParser(); IToyRobot robot = new ToyRobot(); var simulator = new Simulator.Simulator(robot, squareBoard, inputParser); simulator.ProcessCommand("PLACE 1,2,EAST".Split(' ')); simulator.ProcessCommand("MOVE".Split(' ')); simulator.ProcessCommand("MOVE".Split(' ')); simulator.ProcessCommand("LEFT".Split(' ')); simulator.ProcessCommand("MOVE".Split(' ')); var output = simulator.ProcessCommand("REPORT".Split(' ')); Assert.AreEqual("Output: 3,3,NORTH", output); }
protected override void ParseInput(string input) { program = InputParser <BigInteger> .ParseCSVLine(input, BigInteger.Parse).ToList(); }
public ChangeNode(InputParser parser) { _parser = parser; }
private string[] getInput(string part = "1") { return(InputParser.ReadToStringArr(Day, part)); }
public void when_parsing(string input) { Result = new InputParser().Parse(input); }
private ITokenHandler handlerFor(Expression <Func <InputModel, object> > expression) { var property = expression.ToAccessor().InnerProperty; return(InputParser.BuildHandler(property)); }
public void get_the_flag_name_for_a_property() { var property = ReflectionHelper.GetProperty <InputModel>(x => x.OrderFlag); InputParser.ToFlagName(property).ShouldEqual("-order"); }
public void get_the_flag_name_for_a_property_with_an_alias() { var property = ReflectionHelper.GetProperty <InputModel>(x => x.AliasedFlag); InputParser.ToFlagName(property).ShouldEqual("-a"); }
public QueryableStringEndsWithHandler(InputParser inputParser) : base(inputParser) { CanBeNull = false; }
public MongoDbComparableNotGreaterThanHandler(InputParser inputParser) : base(inputParser) { CanBeNull = false; }
public void TestProcessCommand_RotateAndMove() { ISquareBoard squareBoard = new SquareBoard(5, 5); IInputParser inputParser = new InputParser(); IToyRobot robot = new ToyRobot(); var simulator = new Simulator.Simulator(robot, squareBoard, inputParser); simulator.ProcessCommand("PLACE 0,0,NORTH".Split(' ')); simulator.ProcessCommand("RIGHT".Split(' ')); simulator.ProcessCommand("MOVE".Split(' ')); simulator.ProcessCommand("LEFT".Split(' ')); simulator.ProcessCommand("MOVE".Split(' ')); var output = simulator.ProcessCommand("REPORT".Split(' ')); Assert.AreEqual("Output: 1,1,NORTH", output); }
public Neo4JComparableGreaterThanOrEqualsHandler(InputParser inputParser) : base(inputParser) { CanBeNull = false; }