public DeliverAverageSpeedFvdResponse GetDeliverAverageSpeedFvdResponse(DeliverAverageSpeedFvdRequest deliverAverageSpeedFvdRequest) { log.Info("New DeliverAverageSpeedFvdRequest received."); D2LogicalModel d2LogicalModel = deliverAverageSpeedFvdRequest.d2LogicalModel; FusedDataPublication fusedDataPublication = null; // Validate D2LogicalModel if (!ExampleDataCheckOk(d2LogicalModel)) { throw new SoapException("Incoming request does not appear to be valid!", SoapException.ClientFaultCode); } // FusedDataPublication contains the journeytime, direction, code, region, etc. try { fusedDataPublication = (FusedDataPublication)d2LogicalModel.payloadPublication; if (fusedDataPublication != null && fusedDataPublication.fusedData[0] != null) { // You could use the FusedDataPublication and extract the corresponding fields. log.Debug("createdUtc is " + fusedDataPublication.fusedData[0].createdUtc.ToString()); ProcessedTrafficData[] trafficData = fusedDataPublication.fusedData[0].linkData; if (trafficData.Count() > 0) { log.Debug(string.Format("speedFvdOnlyKph {0}", trafficData[0].speedFvdOnlyKph)); } } } catch (Exception e) { log.Error("Error while obtaining FusedDataPublication."); log.Error(e.Message); throw new SoapException("Error while obtaining FusedDataPublication.", SoapException.ServerFaultCode, e); } DeliverAverageSpeedFvdResponse response = new DeliverAverageSpeedFvdResponse(); response.status = "DeliverAverageSpeedFvdRequest: Successful Delivery"; return response; }
public void CheckErrorInGetDeliverAverageSpeedFvdResponseTest() { IAverageSpeedFvdService averageSpeedFvdService = new AverageSpeedFvdService(); DeliverAverageSpeedFvdRequest deliverAverageSpeedFvdRequest = new DeliverAverageSpeedFvdRequest(); model = null; // This will be checked by ExampleDataCheckOk(d2LogicalModel) deliverAverageSpeedFvdRequest.d2LogicalModel = model; string expected = "DeliverAverageSpeedFvdRequest: Successful Delivery"; string actual; // This should cause a SoapException actual = (averageSpeedFvdService.GetDeliverAverageSpeedFvdResponse(deliverAverageSpeedFvdRequest)).status; Assert.AreEqual(expected, actual); }
public void CheckValidGetDeliverAverageSpeedFvdResponseTest() { IAverageSpeedFvdService averageSpeedFvdService = new AverageSpeedFvdService(); DeliverAverageSpeedFvdRequest deliverAverageSpeedFvdRequest = new DeliverAverageSpeedFvdRequest(); deliverAverageSpeedFvdRequest.d2LogicalModel = model; string expected = "DeliverAverageSpeedFvdRequest: Successful Delivery"; string actual; actual = (averageSpeedFvdService.GetDeliverAverageSpeedFvdResponse(deliverAverageSpeedFvdRequest)).status; Assert.AreEqual(expected, actual); }