//[Test] //public void GetDataTransferObjects() //{ // XDocument benchmark = null; // DataTransferIndices dtiList = null, dtiPage = new DataTransferIndices(); // DataTransferObjects dtos = null; // Manifest manifest = null; // int page = 25; // manifest = _dxfrProvider.GetManifest(_settings["ProjectName"], _settings["ApplicationName"]); // dtiList = // _dxfrProvider.GetDataTransferIndicesWithManifest( // _settings["ProjectName"], _settings["ApplicationName"], // _settings["GraphName"], "MD5", manifest); // dtiPage.DataTransferIndexList = dtiList.DataTransferIndexList.GetRange(0, page); // dtos = _dxfrProvider.GetDataTransferObjects(_settings["ProjectName"], _settings["ApplicationName"], // _settings["GraphName"], dtiPage); // string path = String.Format( // "{0}DxfrGetDataTransferObjects.xml", // _settings["AppDataPath"] // ); // XDocument xDocument = ToXml(dtos.DataTransferObjectList); // xDocument.Save(path); // Assert.AreNotEqual(null, xDocument); // benchmark = XDocument.Load(path); // String dtosString = ToXml(dtos.DataTransferObjectList).ToString(); // String benchmarkString = benchmark.ToString(); // Assert.AreEqual(dtosString, benchmarkString); //} //[Test] public void GetDataTransferObjectsWithDxoRequest() { XDocument benchmark = null; DataTransferIndices dtiList = null; DataTransferObjects dtos = null; DxiRequest dxiRequest = new DxiRequest(); dxiRequest.DataFilter = new DataFilter(); dxiRequest.DataFilter.Expressions.Add( new Expression { PropertyName = "PipingNetworkSystem.NominalDiameter.valValue", Values = new Values { "80" }, RelationalOperator = RelationalOperator.EqualTo } ); dxiRequest.DataFilter.OrderExpressions.Add( new OrderExpression { PropertyName = "PipingNetworkSystem.IdentificationByTag.valIdentifier", SortOrder = SortOrder.Asc } ); dxiRequest.Manifest = _dxfrProvider.GetManifest(_settings["ProjectName"], _settings["ApplicationName"]); dtiList = _dxfrProvider.GetDataTransferIndicesWithFilter( _settings["ProjectName"], _settings["ApplicationName"], _settings["GraphName"], "MD5", dxiRequest); DxoRequest dxoRequest = new DxoRequest(); dxoRequest.DataTransferIndices = new DataTransferIndices(); //int page = 25; dxoRequest.Manifest = _dxfrProvider.GetManifest(_settings["ProjectName"], _settings["ApplicationName"]); //dxoRequest.DataTransferIndices.DataTransferIndexList = dtiList.DataTransferIndexList.GetRange(0, page); dxoRequest.DataTransferIndices = dtiList; dtos = _dxfrProvider.GetDataTransferObjects(_settings["ProjectName"], _settings["ApplicationName"], _settings["GraphName"], dxoRequest, false); string path = String.Format( "{0}DxfrGetDataTransferObjectsWithDxoRequest.xml", _settings["AppDataPath"] ); XDocument xDocument = ToXml(dtos.DataTransferObjectList); xDocument.Save(path); Assert.AreNotEqual(null, xDocument); benchmark = XDocument.Load(path); String dtosString = ToXml(dtos.DataTransferObjectList).ToString(); String benchmarkString = benchmark.ToString(); Assert.AreEqual(dtosString, benchmarkString); }
//[Test] public void PostDataTransferObjects() { XDocument benchmark = null; Response response = null; DxoRequest dxoRequest = new DxoRequest(); DataTransferObjects postDtos = null; List <DataTransferObject> dtoList = null; DxiRequest dxiRequest = new DxiRequest(); dxiRequest.DataFilter = new DataFilter(); DataTransferIndices dtiList = null; dxiRequest.DataFilter.Expressions.Add( new Expression { PropertyName = "PipingNetworkSystem.NominalDiameter.valValue", Values = new Values { "80" }, RelationalOperator = RelationalOperator.EqualTo } ); dxiRequest.DataFilter.OrderExpressions.Add( new OrderExpression { PropertyName = "PipingNetworkSystem.IdentificationByTag.valIdentifier", SortOrder = SortOrder.Asc } ); dxiRequest.Manifest = _dxfrProvider.GetManifest(_settings["ProjectName"], _settings["ApplicationName"]); dtiList = _dxfrProvider.GetDataTransferIndicesWithFilter( _settings["ProjectName"], _settings["ApplicationName"], _settings["GraphName"], "MD5", dxiRequest); dxoRequest.Manifest = _dxfrProvider.GetManifest(_settings["ProjectName"], _settings["ApplicationName"]); dxoRequest.DataTransferIndices = dtiList; //dxoRequest.DataTransferIndices = // _dxfrProvider.GetDataTransferIndicesWithManifest( // _settings["ProjectName"], _settings["ApplicationName"], // _settings["GraphName"], "MD5", dxoRequest.Manifest); postDtos = _dxfrProvider.GetDataTransferObjects(_settings["ProjectName"], _settings["ApplicationName"], _settings["GraphName"], dxoRequest, false); dtoList = postDtos.DataTransferObjectList; dtoList[0].transferType = TransferType.Delete; dtoList[1].classObjects[1].templateObjects[0].roleObjects[2].oldValue = dtoList[1].classObjects[1].templateObjects[0].roleObjects[2].value; dtoList[1].classObjects[1].templateObjects[0].roleObjects[2].value = "200"; string path = String.Format( "{0}DxfrNewDto.xml", _settings["AppDataPath"] ); benchmark = XDocument.Load(path); DataTransferObject newDto = Utility.DeserializeDataContract <DataTransferObject>(benchmark.ToString()); dtoList.Add(newDto); response = _dxfrProvider.PostDataTransferObjects(_settings["ProjectName"], _settings["ApplicationName"], _settings["GraphName"], postDtos); path = String.Format( "{0}DxfrResponse.xml", _settings["AppDataPath"] ); XDocument xDocument = ToXml(response); xDocument.Save(path); Assert.AreNotEqual(null, xDocument); benchmark = XDocument.Load(path); String res = ToXml(response).ToString(); Response xmlResponse = Utility.DeserializeDataContract <Response>(benchmark.ToString()); Assert.AreEqual(response.Level.ToString(), xmlResponse.Level.ToString()); foreach (Status status in response.StatusList) { foreach (Status xmlStatus in xmlResponse.StatusList) { Assert.AreEqual(status.Messages.ToString(), xmlStatus.Messages.ToString()); Assert.AreEqual(status.Identifier, xmlStatus.Identifier); xmlResponse.StatusList.Remove(xmlStatus); break; } } //restore the table ResetDatabase(); }
public void GetDataTransferObjectsWithManifest(string scope, string app, string graph, DxoRequest dxoRequest, bool includeContent) { try { if (IsAsync()) { string statusURL = _dtoProvider.AsyncGetDataTransferObjects(scope, app, graph, dxoRequest, includeContent); WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Accepted; WebOperationContext.Current.OutgoingResponse.Headers["location"] = statusURL; } else { DataTransferObjects dtos = _dtoProvider.GetDataTransferObjects(scope, app, graph, dxoRequest, includeContent); HttpContext.Current.Response.ContentType = "application/xml"; HttpContext.Current.Response.Write(Utility.SerializeDataContract <DataTransferObjects>(dtos)); } } catch (Exception ex) { ExceptionHander(ex); } }