public static DeserializeResponseFromByteArray ( byte byteArray, int startIndex ) : |
||
byteArray | byte | Server returned message. |
startIndex | int | The index special where start. |
리턴 |
/// <summary> /// This method is used to validate the sub response according to the current record sub request token and sub request type. /// </summary> /// <param name="rawResponse">Specify the raw XML string response returned by the protocol server.</param> /// <param name="site">An object provides logging, assertions, and SUT adapters for test code onto its execution context.</param> public void Validate(string rawResponse, ITestSite site) { // Extract the sub response whose token equals the SubToken value. XmlDocument subResponseDocument = this.ExtractSubResponseNode(rawResponse); // De-serialize the sub response to instance object subResponse = this.SerializeSubResponse(subResponseDocument, site); // Try to parse the MS-FSSHTTPB structure if (subResponse is CellSubResponseType) { // If the sub request type is CellSubRequestType, then indicating that there is one MS-FSSHTTPB response embedded. Try parse this an capture all the related requirements. CellSubResponseType cellSubResponse = subResponse as CellSubResponseType; if (cellSubResponse.SubResponseData != null && cellSubResponse.SubResponseData.Text.Length == 1) { string subResponseBase64 = cellSubResponse.SubResponseData.Text[0]; byte[] subResponseBinary = Convert.FromBase64String(subResponseBase64); FsshttpbResponse fsshttpbResponse = FsshttpbResponse.DeserializeResponseFromByteArray(subResponseBinary, 0); if (fsshttpbResponse.DataElementPackage != null && fsshttpbResponse.DataElementPackage.DataElements != null) { // If the response data elements is complete, then try to verify the requirements related in the MS-FSSHTPD foreach (DataElement storageIndex in fsshttpbResponse.DataElementPackage.DataElements.Where(dataElement => dataElement.DataElementType == DataElementType.StorageIndexDataElementData)) { // Just build the root node to try to parse the signature related requirements, no need to restore the result. new RootNodeObject.RootNodeObjectBuilder().Build( fsshttpbResponse.DataElementPackage.DataElements, storageIndex.DataElementExtendedGUID); } } if (SharedContext.Current.IsMsFsshttpRequirementsCaptured) { new MsfsshttpbAdapterCapture().VerifyTransport(site); // Capture the response related requirements new MsfsshttpbAdapterCapture().VerifyFsshttpbResponse(fsshttpbResponse, site); } } } // Validating the fragment of the sub response // Record the validation errors and warnings. ValidationResult result = SchemaValidation.ValidateXml(subResponseDocument.OuterXml); if (!SharedContext.Current.IsMsFsshttpRequirementsCaptured) { if (result != ValidationResult.Success) { // Add error log site.Assert.Fail("Schema validation fails, the reason is " + SchemaValidation.GenerateValidationResult()); } // No need to run the capture code, just return. return; } if (result == ValidationResult.Success) { // Capture the requirement related to the sub response token. MsfsshttpAdapterCapture.ValidateSubResponseToken(site); // Call corresponding sub response capture code. this.InvokeCaptureCode(subResponse, site); } else { // Add error log site.Assert.Fail("Schema validation fails, the reason is " + SchemaValidation.GenerateValidationResult()); } }