public async Task <IActionResult> AddRegion(RegionInputDto regionInput) { CoordinateParser coordinateParser = new CoordinateParser(); Coordinate[] parsedCoordinates = await coordinateParser.Parse(regionInput.KmlUrl); Region region = new Region { Name = regionInput.Name }; _context.Add(region); await _context.SaveChangesAsync(); foreach (Coordinate coordinate in parsedCoordinates) { Coordinate coordinateTransition = new Coordinate { Lat = coordinate.Lat, Lng = coordinate.Lng, RegionId = region.Id, }; _context.Add(coordinateTransition); await _context.SaveChangesAsync(); } return(Ok()); }
/// <summary> /// Parse the command and calls the appropriate method /// </summary> /// <param name="command">Entered command</param> private void ExecuteCommand(string command) { switch (command) { case "exit": this.isGameRunning = false; Console.WriteLine("Goodbye!"); break; case "top": this.consoleRenderer.PrintTopPlayers(this.topPlayers.PlayersMoves); Console.WriteLine("Press any key to continue..."); Console.ReadKey(); break; case "restart": this.StartNewGame(); break; default: int[] cordinates = CoordinateParser.Parse(command); this.Shoot(cordinates); break; } }
public void Test_ParsingCordinates_ShouldReturnArrayOfCordinates() { var coordinates = CoordinateParser.Parse("4 8"); Assert.AreEqual(4, coordinates[0]); Assert.AreEqual(8, coordinates[1]); }
public void TestItReturnsInvalidOnBadData(string latitude, string longitude) { Coordinate coordinate = CoordinateParser.Parse(latitude, longitude); Assert.Equal(CoordinateParser.InvalidCoordinate, coordinate); }
[InlineData("N054.60.44.000", "W006.60.23.000")] // 60 minutes public void TestItParsesValidCoordinates(string latitude, string longitude) { Assert.Equal(new Coordinate(latitude, longitude), CoordinateParser.Parse(latitude, longitude)); }
public void Test_ParsingWrongCordinates_ShouldThrowInvalidCoordinates() { var coordinates = CoordinateParser.Parse("asd qwe"); }
public void Test_ParsingOutsideOfGameBoardCordinates_ShouldThrowInvalidCoordinates() { var coordinates = CoordinateParser.Parse("22 20"); }
public void Test_ParsingCordinates_ShouldThrowInvalidCommand() { var coordinates = CoordinateParser.Parse("12"); }
public void Can_Parse(char coordinate, int expectedResult) { var result = CoordinateParser.Parse(coordinate); Assert.Equal(expectedResult, result); }