public void SuggestMarshallTest() { var operation = service_model.FindOperation("Suggest"); var request = InstantiateClassGenerator.Execute <SuggestRequest>(); var marshaller = new SuggestRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("Suggest", request, internalRequest, service_model); var webResponse = new WebResponseData { Headers = { { "x-amzn-RequestId", Guid.NewGuid().ToString() }, { "x-amz-crc32", "0" } } }; var payloadResponse = new JsonSampleGenerator(service_model, operation.ResponseStructure).Execute(); webResponse.Headers["Content-Length"] = UTF8Encoding.UTF8.GetBytes(payloadResponse).Length.ToString(); var context = new JsonUnmarshallerContext(Utils.CreateStreamFromString(payloadResponse), false, webResponse); ResponseUnmarshaller unmarshaller = SuggestResponseUnmarshaller.Instance; var response = unmarshaller.Unmarshall(context) as SuggestResponse; InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); }
public void Suggest_SearchExceptionMarshallTest() { var operation = service_model.FindOperation("Suggest"); var request = InstantiateClassGenerator.Execute <SuggestRequest>(); var marshaller = new SuggestRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("Suggest", request, internalRequest, service_model); var exception = operation.Exceptions.First(e => e.Name.Equals("SearchException")); var webResponse = new WebResponseData { Headers = { { "x-amzn-RequestId", Guid.NewGuid().ToString() }, { "x-amz-crc32", "0" }, { "x-amzn-ErrorType", "SearchException" }, } }; var payloadResponse = new JsonSampleGenerator(service_model, exception).Execute(); webResponse.Headers["Content-Length"] = UTF8Encoding.UTF8.GetBytes(payloadResponse).Length.ToString(); var context = new JsonUnmarshallerContext(Utils.CreateStreamFromString(payloadResponse), true, webResponse, true); var response = SuggestResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); }
public void SuggestMarshallTest() { var operation = service_model.FindOperation("Suggest"); var request = InstantiateClassGenerator.Execute<SuggestRequest>(); var marshaller = new SuggestRequestMarshaller(); var internalRequest = marshaller.Marshall(request); RequestValidator.Validate("Suggest", request, internalRequest, service_model); var webResponse = new WebResponseData { Headers = { {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"} } }; var payloadResponse = new JsonSampleGenerator(service_model, operation.ResponseStructure).Execute(); webResponse.Headers.Add("Content-Length", UTF8Encoding.UTF8.GetBytes(payloadResponse).Length.ToString()); var context = new JsonUnmarshallerContext(Utils.CreateStreamFromString(payloadResponse), false, webResponse); ResponseUnmarshaller unmarshaller = SuggestResponseUnmarshaller.Instance; var response = unmarshaller.Unmarshall(context) as SuggestResponse; InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); }