public void ParseInvalidQueries(string queryString) { Query query = new Query(queryString); var result = InputInterpreter.Parse(query); Assert.AreEqual(null, result); }
public void ParseValidQueries(string queryString, double result) { Query query = new Query(queryString); var convertModel = InputInterpreter.Parse(query); Assert.AreEqual(result, convertModel.Value); }
public void Test_example_inputs(string inputStr, IEnumerable <Move> expected) { IInputInterpreter inputInterpreter = new InputInterpreter(); var actual = inputInterpreter.Interpret(inputStr); Assert.Equal(expected, actual); }
protected override void Start() { base.Start(); inputInterp = InterfaceManager.GetInputInterpreter(); /* if(this.useGUILayout) * print ("Use GUI is tru");*/ }
/// <summary> Gets version status from github. </summary> /// <returns> The current version status. </returns> private static VersionStatus GetVersionStatus() { try { var interpreter = new InputInterpreter(); var client = new GitHubClient(new ProductHeaderValue("butterflow-ui")); var releases = client.Repository.Release.GetAll("wagesj45", "butterflow-ui").Result; if (releases.Any()) { var latest = releases.First(); decimal latestMajor = 0, latestMinor = 0, latestPatch = 0, currentMajor = 0, currentMinor = 0, currentPatch = 0; var regex = new Regex(REGEX_VERSION); foreach (Match match in regex.Matches(latest.TagName)) { latestMajor = interpreter.ComputeExpression(match.Groups["Major"].Value); latestMinor = interpreter.ComputeExpression(match.Groups["Minor"].Value); latestPatch = interpreter.ComputeExpression(match.Groups["Patch"].Value); } foreach (Match match in regex.Matches(Assembly.GetExecutingAssembly().GetName().Version.ToString())) { currentMajor = interpreter.ComputeExpression(match.Groups["Major"].Value); currentMinor = interpreter.ComputeExpression(match.Groups["Minor"].Value); currentPatch = interpreter.ComputeExpression(match.Groups["Patch"].Value); } if (latestMajor == currentMajor && latestMinor == currentMinor && latestPatch == currentPatch) { return(VersionStatus.Current); } if (latestMajor >= currentMajor && latestMinor >= currentMinor && latestPatch >= currentPatch) { return(VersionStatus.Behind); } return(VersionStatus.Custom); } } catch (Exception e) { //There was an issue connecting to Github. This could be caused by a missing network connection. //We can safely ignore an error in this process and proceed, falling through to the default connection //value of Unknown. } return(VersionStatus.Unknown); }
public void EnsureThatEverythingIsTrackedCorrectly() { var mock = new MockFactory(); Mock<IGameOutputAdapter> outputAdapterMock = mock.CreateMock<IGameOutputAdapter>(); outputAdapterMock.Expects.AtLeastOne.MethodWith(x => x.NotifyReady()); outputAdapterMock.Expects.AtLeastOne.MethodWith(x => x.NotifyEndOfTurn()); var gameManager = new GameManager(outputAdapterMock.MockObject); var inputInterpreter = new InputInterpreter(gameManager); inputInterpreter.Interpret("turn 0"); inputInterpreter.Interpret("rows 10"); inputInterpreter.Interpret("cols 10"); inputInterpreter.Interpret("ready"); inputInterpreter.Interpret("turn 1"); inputInterpreter.Interpret("a 0 5 0"); inputInterpreter.Interpret("go"); Ant initAnt = (from row in Enumerable.Range(0, GameContext.Map.Rows) from col in Enumerable.Range(0, GameContext.Map.Columns) let tile = GameContext.Map.At(row, col) where tile.CurrentAnt != null select tile.CurrentAnt ).Single(); initAnt.MovementStrategy = new MoveDirection(initAnt, Direction.South); for (int turn = 2; turn < 10; turn++) { var expectedRow = turn - 2; var expectedColumn = initAnt.CurrentPosition.Column; inputInterpreter.Interpret("turn " + turn); inputInterpreter.Interpret(string.Format("a {0} {1} 0", expectedRow, expectedColumn)); outputAdapterMock.Expects.One .MethodWith(adapter => adapter.MoveAnt(expectedRow, expectedColumn, Direction.South)); inputInterpreter.Interpret("go"); Assert.IsTrue(initAnt.MovementStrategy is MoveDirection); } mock.VerifyAllExpectationsHaveBeenMet(); }
// Use this for initialization protected void Awake() { _delRoyal = null; _orders = new Queue <Order>(); _location = null; currentlySelected = false; inputInterp = InterfaceManager.GetInputInterpreter(); _deployed = false; currentOrder = null; _retinue = GetComponentInChildren <MorphTracker>(); if (_retinue == null) { Debug.LogError("Error in Delegation object structure"); Destroy(this); } }
/// <summary> Gets version status from github. </summary> /// <returns> The current version status. </returns> private static VersionStatus GetVersionStatus() { var interpreter = new InputInterpreter(); var client = new GitHubClient(new ProductHeaderValue("butterflow-ui")); var releases = client.Repository.Release.GetAll("wagesj45", "butterflow-ui").Result; if (releases.Any()) { var latest = releases.First(); decimal latestMajor = 0, latestMinor = 0, latestPatch = 0, currentMajor = 0, currentMinor = 0, currentPatch = 0; var regex = new Regex(REGEX_VERSION); foreach (Match match in regex.Matches(latest.TagName)) { latestMajor = interpreter.ComputeExpression(match.Groups["Major"].Value); latestMinor = interpreter.ComputeExpression(match.Groups["Minor"].Value); latestPatch = interpreter.ComputeExpression(match.Groups["Patch"].Value); } foreach (Match match in regex.Matches(Assembly.GetExecutingAssembly().GetName().Version.ToString())) { currentMajor = interpreter.ComputeExpression(match.Groups["Major"].Value); currentMinor = interpreter.ComputeExpression(match.Groups["Minor"].Value); currentPatch = interpreter.ComputeExpression(match.Groups["Patch"].Value); } if (latestMajor == currentMajor && latestMinor == currentMinor && latestPatch == currentPatch) { return(VersionStatus.current); } if (latestMajor >= currentMajor && latestMinor >= currentMinor && latestPatch >= currentPatch) { return(VersionStatus.behind); } return(VersionStatus.custom); } return(VersionStatus.unknown); }
public void PrefixesDegrees(string[] input, string[] expectedResult) { InputInterpreter.DegreePrefixer(ref input); Assert.AreEqual(expectedResult, input); }
public void HandlesShorthandFeetInchNotation(string[] input, string[] expectedResult) { InputInterpreter.ShorthandFeetInchHandler(ref input, CultureInfo.InvariantCulture); Assert.AreEqual(expectedResult, input); }
public void InsertsSpaces(string[] input, string[] expectedResult) { InputInterpreter.InputSpaceInserter(ref input); Assert.AreEqual(expectedResult, input); }
public void RegexSplitsInput(string[] input, string[] expectedResult) { string[] shortsplit = InputInterpreter.RegexSplitter(input); Assert.AreEqual(expectedResult, shortsplit); }
public static void SetInputInterpreter(InputInterpreter inputInterpreter) { _inputInterp = inputInterpreter; }
public Graph(string townsGraph) { _edges = InputInterpreter.GetEdgesFrom(townsGraph).ToList(); }