public IActionResult Get([FromQuery] GridCellMapper gridMapper) { try { //First Convert from the mapped valudes to actual numeric grid values GridCellPosition position = new GridCellPosition(gridMapper.GetNumericColumn(), gridMapper.GetNumericRow()); //Check that the position is valid if (_shapeProcessor.ValidateGridCellPosition(position)) { //Yep, all's Ok - go get the shape IShape triangle = _shapeProcessor.GetShape(position); return(Ok(triangle)); } else { //Not found return(NotFound()); } } catch (ArgumentOutOfRangeException ex) { //Out of range - means not found _logger.LogError(ex.Message); return(NotFound()); } catch (Exception ex) { _logger.LogError(ex.Message); } //Something has gone wrong. return(BadRequest()); }
public void TestValidGridNumericValuesFor_A_1() { _gridCellMapper.Row = "A"; _gridCellMapper.Column = 1; Assert.AreEqual(1, _gridCellMapper.GetNumericRow()); Assert.AreEqual(1, _gridCellMapper.GetNumericColumn()); }