public void ThenTheFollowingMachinesShouldBeReturned(Gherkin.Ast.DataTable dataTable) { var expectedResult = new GetMachinesResult(); var expectedMachineList = new List <MachineStatus>(); foreach (var row in dataTable.Rows.Skip(1)) { expectedMachineList.Add(new MachineStatus { lastKnownDesignName = row.Cells.ElementAt(0).Value, lastKnownLayerId = ushort.Parse(row.Cells.ElementAt(1).Value), lastKnownTimeStamp = DateTime.Parse(row.Cells.ElementAt(2).Value), lastKnownLatitude = Math.Round(double.Parse(row.Cells.ElementAt(3).Value), 12), lastKnownLongitude = Math.Round(double.Parse(row.Cells.ElementAt(4).Value), 12), lastKnownX = Math.Round(double.Parse(row.Cells.ElementAt(5).Value), 12), lastKnownY = Math.Round(double.Parse(row.Cells.ElementAt(6).Value), 12), AssetId = long.Parse(row.Cells.ElementAt(7).Value), MachineName = row.Cells.ElementAt(8).Value, IsJohnDoe = bool.Parse(row.Cells.ElementAt(9).Value) }); } var actualResult = JsonConvert.DeserializeObject <GetMachinesResult>(GetResponseHandler.CurrentResponse.ToString()); expectedResult.MachineStatuses = expectedMachineList.ToArray(); ObjectComparer.RoundAllArrayElementsProperties(actualResult.MachineStatuses, roundingPrecision: 8); ObjectComparer.RoundAllArrayElementsProperties(expectedResult.MachineStatuses, roundingPrecision: 8); ObjectComparer.AssertAreEqual(actualResultObj: actualResult, expectedResultObj: expectedResult); }
public void DigestScenarioStepValues_Sets_Value_As_DataTable_When_DataTable_And_Other_Args_Present() { //arrange. var sut = new DataTableArgument(); var dataTable = new Gherkin.Ast.DataTable(new Gherkin.Ast.TableRow[] { new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[] { new Gherkin.Ast.TableCell(null, "First argument"), new Gherkin.Ast.TableCell(null, "Second argument"), new Gherkin.Ast.TableCell(null, "Result"), }), new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[] { new Gherkin.Ast.TableCell(null, "1"), new Gherkin.Ast.TableCell(null, "2"), new Gherkin.Ast.TableCell(null, "3"), }), new Gherkin.Ast.TableRow(null, new Gherkin.Ast.TableCell[] { new Gherkin.Ast.TableCell(null, "a"), new Gherkin.Ast.TableCell(null, "b"), new Gherkin.Ast.TableCell(null, "c"), }) }); //act. sut.DigestScenarioStepValues(new string[] { "1", "2", "3" }, dataTable); //assert. Assert.Same(dataTable, sut.Value); }
public void ThenIShouldGetTheFollowingProjectStatistics(Gherkin.Ast.DataTable dataTable) { var expectedResult = new ProjectStatistics(); foreach (var row in dataTable.Rows.Skip(1)) { expectedResult.startTime = DateTime.Parse(row.Cells.ElementAt(0).Value); expectedResult.endTime = DateTime.Parse(row.Cells.ElementAt(1).Value); expectedResult.cellSize = double.Parse(row.Cells.ElementAt(2).Value); expectedResult.indexOriginOffset = int.Parse(row.Cells.ElementAt(3).Value); expectedResult.extents = new BoundingBox3DGrid { maxX = double.Parse(row.Cells.ElementAt(4).Value), maxY = double.Parse(row.Cells.ElementAt(5).Value), maxZ = double.Parse(row.Cells.ElementAt(6).Value), minX = double.Parse(row.Cells.ElementAt(7).Value), minY = double.Parse(row.Cells.ElementAt(8).Value), minZ = double.Parse(row.Cells.ElementAt(9).Value) }; } ObjectComparer.RoundAllDoubleProperties(expectedResult.extents, roundingPrecision: 2); ObjectComparer.RoundAllDoubleProperties(PostRequestHandler.CurrentResponse.extents, roundingPrecision: 2); ObjectComparer.AssertAreEqual(actualResultObj: PostRequestHandler.CurrentResponse, expectedResultObj: expectedResult); }
public void Then_inverse(string a, string b, int rows, int cols, DataTable dataTable) { var expectedId = $"{a} * {b}"; Given_matrix(expectedId, dataTable); Assert.True(cache[expectedId].Equals(MatrixOperations.Multiply(cache[a], cache[b]))); cache.Remove(expectedId); }
public void Then_transpose(string id, DataTable dataTable) { var expectedId = $"transpose({id})"; Given_matrix(expectedId, dataTable); Assert.True(cache[expectedId].Equals(MatrixOperations.Transpose(cache[id], false))); cache.Remove(expectedId); }
public void And_matrix_equals(string id, int rows, int cols, DataTable dataTable) { var expectedId = $"expected_{id}"; Given_matrix_with_dimensions(rows, cols, expectedId, dataTable); Then_matrix_equals(id, expectedId); cache.Remove(expectedId); }
private void ScheduleAppointmentsFromTable(Gherkin.Ast.DataTable dataTable) { foreach (var row in dataTable.Rows.Skip(1)) { var givenAppointment = convertRowToAppointment(row); appointmentService.ScheduleAppointment(givenAppointment); } }
public void Then_matrix(string t, int rows, int cols, DataTable dataTable) { var expectedId = $"expected_{t}"; Given_matrix_with_dimensions(rows, cols, expectedId, dataTable); Assert.Equal(cache[expectedId], cache[t]); cache.Remove(expectedId); }
public void Then_inverse(string id, int rows, int cols, DataTable dataTable) { var expectedId = $"inverse({id})"; Given_matrix(expectedId, dataTable); Assert.True(cache[expectedId].Equals(MatrixOperations.Invert(cache[id], MatrixOperation.Cofactor))); Assert.True(cache[expectedId].Equals(MatrixOperations.Invert(cache[id], MatrixOperation.Gauss))); cache.Remove(expectedId); }
public void And_shape_has(string id, DataTable dataTable) { IFigure shape = figure[id]; double ambient = shape.Material.Ambient; double transparency = shape.Material.Transparency; double refractiveIndex = shape.Material.RefractiveIndex; bool hasPattern = false; foreach (var row in dataTable.Rows) { var cells = row.Cells.ToArray(); switch (cells[0].Value) { case "material.ambient": ambient = double.Parse(cells[1].Value); break; case "material.transparency": transparency = double.Parse(cells[1].Value); break; case "material.refractive_index": refractiveIndex = double.Parse(cells[1].Value); break; case "material.pattern": if (!cells[1].Value.Equals("test_pattern()")) { throw new NotSupportedException(); } hasPattern = true; break; default: throw new NotImplementedException(); } } var material = hasPattern ? (IMaterial) new PatternMaterial(new PatternsTest.TestPattern(), ambient, shape.Material.Diffuse, shape.Material.Specular, shape.Material.Shininess, shape.Material.Reflective, refractiveIndex, transparency) : (IMaterial) new SolidColorMaterial(shape.Material.GetColor(Tuple4.ZeroPoint), ambient, shape.Material.Diffuse, shape.Material.Specular, shape.Material.Shininess, shape.Material.Reflective, refractiveIndex, transparency); shape.Material = material; }
public void Que_eu_possua_um_participante_com_os_seguintes_dados(Gherkin.Ast.DataTable dataTable) { foreach (var row in dataTable.Rows.Skip(1)) { _examplePerson.Name = row.Cells.ElementAt(1).Value.ToString(); _examplePerson.Cpf = row.Cells.ElementAt(2).Value.ToString(); _examplePerson.BirthDate = DateTime.Parse(row.Cells.ElementAt(2).Value.ToString()); } }
public void AndITryToUndoTheFollowingEditsForProject(long pId, Gherkin.Ast.DataTable dataTable) { foreach (var row in dataTable.Rows.Skip(1)) { dynamic undoEditRequest = new JObject(); undoEditRequest.ProjectId = pId; undoEditRequest.Undo = true; undoEditRequest.DataEdit = JToken.FromObject(dataEditContext.DataEdits[int.Parse(row.Cells.ElementAt(0).Value)]); editDataRequester.DoValidRequest(undoEditRequest); } }
public void AndTheResultMatchesTheFollowingDataEdits(Gherkin.Ast.DataTable dataTable) { var expectedResult = new GetEditDataResult(); var edits = new List <ProductionDataEdit>(); foreach (var row in dataTable.Rows.Skip(1)) { edits.Add(dataEditContext.DataEdits[int.Parse(row.Cells.ElementAt(0).Value)]); } expectedResult.dataEdits = edits; ObjectComparer.AssertAreEqual(actualResultObj: edits, expectedResultObj: expectedResult.dataEdits); }
private static global::Gherkin.Ast.Step DigestExampleValuesIntoStep(global::Gherkin.Ast.ScenarioOutline @this, string exampleName, int exampleRowIndex, Dictionary <string, string> rowValues, global::Gherkin.Ast.Step outlineStep) { string matchEvaluator(Match match) { var placeholderKey = match.Groups[1].Value; if (!rowValues.ContainsKey(placeholderKey)) { throw new InvalidOperationException($"Examples table did not provide value for `{placeholderKey}`. Scenario outline: `{@this.Name}`. Examples: `{exampleName}`. Row index: {exampleRowIndex}."); } var placeholderValue = rowValues[placeholderKey]; return(placeholderValue); } var stepText = _placeholderRegex.Replace(outlineStep.Text, matchEvaluator); var stepArgument = outlineStep.Argument; if (stepArgument is DataTable) { var processedHeaderRow = false; var digestedRows = new List <TableRow>(); foreach (var row in ((DataTable)stepArgument).Rows) { if (!processedHeaderRow) { digestedRows.Add(row); processedHeaderRow = true; } else { var digestedCells = row.Cells.Select(r => new TableCell(r.Location, _placeholderRegex.Replace(r.Value, matchEvaluator))); digestedRows.Add(new TableRow(row.Location, digestedCells.ToArray())); } } stepArgument = new DataTable(digestedRows.ToArray()); } var scenarioStep = new global::Gherkin.Ast.Step( outlineStep.Location, outlineStep.Keyword, stepText, stepArgument); return(scenarioStep); }
public void GivenISubmitTheFollowingDataEditsToProject(long pId, Gherkin.Ast.DataTable dataTable) { foreach (var row in dataTable.Rows.Skip(1)) { _ = int.Parse(row.Cells.ElementAt(0).Value); dynamic doEditRequest = new JObject(); doEditRequest.ProjectId = pId; doEditRequest.Undo = false; doEditRequest.DataEdit = JToken.FromObject(dataEditContext.DataEdits[int.Parse(row.Cells.ElementAt(0).Value)]); editDataResult = editDataRequester.DoValidRequest(doEditRequest); } }
public void GivenTheseCoordinates(Gherkin.Ast.DataTable dataTable) { var coordinates = new List <TwoDConversionCoordinate>(); foreach (var row in dataTable.Rows.Skip(1)) { coordinates.Add(new TwoDConversionCoordinate { x = double.Parse(row.Cells.ElementAt(0).Value), y = double.Parse(row.Cells.ElementAt(1).Value) }); } PostRequestHandler.CurrentRequest["conversionCoordinates"] = JToken.FromObject(coordinates.ToArray()); }
/// <summary> /// Converts the provided <see cref="Gherkin.Ast.StepArgument"/> instance into a <see cref="Augurk.Entities.Table"/> instance. /// </summary> /// <param name="table">The <see cref="Gherkin.Ast.StepArgument"/> instance that should be converted.</param> /// <returns>The converted <see cref="Augurk.Entities.Table"/> instanc, or <c>null</c> if the provided <paramref name="argument"/> is not a <see cref="Gherkin.Ast.DataTable"/>.</returns> public static Table ConvertToTable(this Gherkin.Ast.StepArgument argument) { Gherkin.Ast.DataTable table = argument as Gherkin.Ast.DataTable; if (table == null) { return(null); } return(new Table { Columns = table.Rows.FirstOrDefault()?.Cells.Select(cell => cell.Value).ToArray(), // Skip the first row as those are the headers Rows = table.Rows.Skip(1).Select(row => row.Cells.Select(cell => cell.Value).ToArray()).ToArray(), Location = table.Location.ConvertToSourceLocation() }); }
public void Given_matrix_with_dimensions(int rows, int cols, string id, DataTable dataTable) { var m = new double[rows, cols]; int r = 0; int c = 0; foreach (var row in dataTable.Rows) { c = 0; foreach (var cell in row.Cells) { m[r, c] = double.Parse(cell.Value); ++c; } ++r; } cache.Add(id, new Matrix(m)); }
public void ThenTheFollowingMachineDesignsShouldBeReturned(Gherkin.Ast.DataTable dataTable) { var expectedResult = new GetMachineDesignResult(); var expectedDesigns = new List <DesignName>(); foreach (var row in dataTable.Rows.Skip(1)) { expectedDesigns.Add(new DesignName { designId = long.Parse(row.Cells.ElementAt(0).Value), designName = row.Cells.ElementAt(1).Value }); } expectedResult.designs = expectedDesigns; AssertObjectsAreEqual(expectedResult); }
public void ThenTheResultShouldBeThese(Gherkin.Ast.DataTable dataTable) { var expectedResult = new CoordinateConversionResult(); var expectedCoordinates = new List <TwoDConversionCoordinate>(); foreach (var row in dataTable.Rows.Skip(1)) { expectedCoordinates.Add(new TwoDConversionCoordinate { x = double.Parse(row.Cells.ElementAt(0).Value), y = double.Parse(row.Cells.ElementAt(1).Value) }); } expectedResult.conversionCoordinates = expectedCoordinates.ToArray(); Assert.Equal(expectedResult, PostRequestHandler.CurrentResponse); }
public void ThenTheFollowingObjectsShouldBeReturned(Gherkin.Ast.DataTable dataTable) { var expectedResult = new ProjectExtentsResult(); foreach (var row in dataTable.Rows.Skip(1)) { expectedResult.ProjectExtents = new BoundingBox3DGrid { maxX = double.Parse(row.Cells.ElementAt(0).Value), maxY = double.Parse(row.Cells.ElementAt(1).Value), maxZ = double.Parse(row.Cells.ElementAt(2).Value), minX = double.Parse(row.Cells.ElementAt(3).Value), minY = double.Parse(row.Cells.ElementAt(4).Value), minZ = double.Parse(row.Cells.ElementAt(5).Value) }; } AssertObjectsAreEqual(expectedResult); }
public void GivenTheFollowingDataEditDetails(Gherkin.Ast.DataTable dataTable) { foreach (var row in dataTable.Rows.Skip(1)) { var onMachineDesignName = row.Cells.ElementAt(4).Value; var liftNumber = row.Cells.ElementAt(5).Value; dataEditContext.DataEdits.Add(new ProductionDataEdit { assetId = int.Parse(row.Cells.ElementAt(1).Value), startUTC = DateTime.Parse(row.Cells.ElementAt(2).Value), endUTC = DateTime.Parse(row.Cells.ElementAt(3).Value), onMachineDesignName = onMachineDesignName == "null" ? null : onMachineDesignName == "Random" ? "VirtualDesign_" + new Random().Next(32768) : onMachineDesignName, liftNumber = liftNumber == "null" ? (int?)null : liftNumber == "Random" ? new Random().Next(32768) : Convert.ToInt32(liftNumber) }); } }
public void ThenTheFollowingLiftDetailsShouldBeReturned(Gherkin.Ast.DataTable dataTable) { var expectedResult = new LayerIdsExecutionResult(); var expectedLayers = new List <LayerIdDetails>(); foreach (var row in dataTable.Rows.Skip(1)) { expectedLayers.Add(new LayerIdDetails { AssetId = long.Parse(row.Cells.ElementAt(0).Value), DesignId = long.Parse(row.Cells.ElementAt(1).Value), LayerId = long.Parse(row.Cells.ElementAt(2).Value), StartDate = DateTime.Parse(row.Cells.ElementAt(3).Value), EndDate = DateTime.Parse(row.Cells.ElementAt(4).Value) }); } expectedResult.LayerIdDetailsArray = expectedLayers.ToArray(); AssertObjectsAreEqual <LayerIdsExecutionResult>(expectedResult); }
public void ThenTheFollowingMachineDesignsShouldBeReturned(Gherkin.Ast.DataTable dataTable) { var expectedResult = new GetSurveydSurfacesResult(); var expectedSurfaces = new List <SurveyedSurfaces>(); foreach (var row in dataTable.Rows.Skip(1)) { expectedSurfaces.Add(new SurveyedSurfaces { AsAtDate = DateTime.Parse(row.Cells.ElementAt(0).Value), Id = long.Parse(row.Cells.ElementAt(1).Value), SurveyedSurface = new DesignDescriptor { file = new FileDescriptor { fileName = row.Cells.ElementAt(2).Value, filespaceId = row.Cells.ElementAt(3).Value } } }); } expectedResult.SurveyedSurfaces = expectedSurfaces; Assert.Equal(expectedResult, result); }
public void When_DataTable_Is_Expected(Gherkin.Ast.DataTable dataTable) { ReceivedDataTable = dataTable; }
public void GivenAScheduleWithTheFollowingAppointments(Gherkin.Ast.DataTable dataTable) { GivenAnEmptySchedule(); ScheduleAppointmentsFromTable(dataTable); }
public void Given_matrix(string id, DataTable dataTable) { var n = dataTable.Rows.Count(); Given_matrix_with_dimensions(n, n, id, dataTable); }
private void MethodWithDataTableArgumentOnly(Gherkin.Ast.DataTable dataTable) { }
private void MethodWithDataTableAndOtherArguments(int param1, string param2, DateTime param3, Gherkin.Ast.DataTable dataTable) { }
public void Then_submatrix_with_dimensions(string id, int row, int col, int rows, int cols, DataTable dataTable) { var minorId = $"submatrix({id}, {row}, {col})"; Given_matrix_with_dimensions(rows, cols, minorId, dataTable); var actualResult = MatrixOperations.Minor(cache[id], row, col); Assert.True(cache[minorId].Equals(actualResult)); cache.Remove(minorId); }