コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public void ThenTheResponseShouldBe(DocString json)
        {
            var expectedJObject = JsonConvert.DeserializeObject <JObject>(json.Content);

            ObjectComparer.RoundAllDoubleProperties(GetResponseHandler.CurrentResponse as JObject, roundingPrecision: 8);
            ObjectComparer.RoundAllDoubleProperties(expectedJObject, roundingPrecision: 8);

            ObjectComparer.AssertAreEqual(actualResultObj: GetResponseHandler.CurrentResponse, expectedResultObj: expectedJObject, ignoreCase: true);
        }
コード例 #4
0
        public void ThenTheResultShouldBeEmpty()
        {
            var expectedResult = new GetEditDataResult
            {
                dataEdits = new List <ProductionDataEdit>()
            };

            ObjectComparer.AssertAreEqual(actualResultObj: getEditDataResult, expectedResultObj: expectedResult);
        }
コード例 #5
0
        public void ThenTheResponseShouldMatchToDecimalPlacesFromTheRepository(int precision, string resultName)
        {
            var actualJObject   = JObject.FromObject(GetResponseHandler.CurrentResponse);
            var expectedJObject = JsonConvert.DeserializeObject <JObject>(GetResponseHandler.ResponseRepo[resultName].ToString());

            ObjectComparer.RoundAllDoubleProperties(actualJObject, roundingPrecision: precision);
            ObjectComparer.RoundAllDoubleProperties(expectedJObject, roundingPrecision: precision);

            ObjectComparer.AssertAreEqual(actualResultObj: actualJObject, expectedResultObj: expectedJObject, resultName: resultName);
        }
コード例 #6
0
        public void ThenTheProductionDataCellDatumResponseShouldMatchResultFromTheRepositoryWithRoundingTo(string resultName, int precision)
        {
            var expectedJObject = JObject.FromObject(PostRequestHandler.ResponseRepo[resultName]);
            var actualJObject   = JObject.FromObject(PostRequestHandler.CurrentResponse);

            ObjectComparer.RoundAllDoubleProperties(actualJObject, precision);
            ObjectComparer.RoundAllDoubleProperties(expectedJObject, precision);

            ObjectComparer.AssertAreEqual(actualResultObj: actualJObject, expectedResultObj: expectedJObject);
        }
コード例 #7
0
        public void ThenTheProductionDataCellDatumResponseShouldMatchResultFromTheRepository(string resultName)
        {
            var expectedResultJson = JsonConvert.SerializeObject(PostRequestHandler.ResponseRepo[resultName], Formatting.Indented);
            var actualResultJson   = JsonConvert.SerializeObject(PostRequestHandler.CurrentResponse, Formatting.Indented);

            ObjectComparer.AssertAreEqual(
                actualResultJson: actualResultJson,
                expectedResultJson: expectedResultJson,
                ignoreCase: true,
                resultName: resultName);
        }
コード例 #8
0
        public void ThenTheResponseShouldBe(DocString json)
        {
            // We deliberately serialize to formatted JSON because if the test fails it's easier to see the actual vs expected which comparing JObjects doesn't give us.
            var expectedJObject = JsonConvert.DeserializeObject <JObject>(json.Content);
            var actualJObject   = JObject.FromObject(PostRequestHandler.CurrentResponse);

            ObjectComparer.RoundAllDoubleProperties(actualJObject, roundingPrecision: 8);
            ObjectComparer.RoundAllDoubleProperties(expectedJObject, roundingPrecision: 8);

            ObjectComparer.AssertAreEqual(actualResultObj: actualJObject, expectedResultObj: expectedJObject);
        }
コード例 #9
0
        public void ThenTheDatumShouldBeDisplayModeReturnCodeValueTimestamp(
            int displayMode, int returnCode, double value, string timestamp)
        {
            var expectedDatumResult = new CellDatumResult
            {
                displayMode = (DisplayMode)displayMode,
                returnCode  = (short)returnCode,
                value       = value,
                timestamp   = Convert.ToDateTime(timestamp)
            };

            ObjectComparer.AssertAreEqual(actualResultObj: cellDatumResult, expectedResultObj: expectedDatumResult);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
        public void ThenTheFirstSavedMachineDetailShouldMatchResultFromTheMachineResultRepo(string resultName)
        {
            if (firstDotMachineStatus.MachineStatuses.Length < 1)
            {
                Assert.True(false, $"Unable to get machine status {firstDotMachineStatus}");
            }

            var actualObj   = JObject.FromObject(firstDotMachineStatus);
            var expectedObj = JObject.FromObject(machineStatusGetter.ResponseRepo[resultName]);

            ObjectComparer.RoundAllDoubleProperties(actualObj, roundingPrecision: 8);
            ObjectComparer.RoundAllDoubleProperties(expectedObj, roundingPrecision: 8);

            ObjectComparer.AssertAreEqual(actualResultObj: actualObj, expectedResultObj: expectedObj);
        }