/* * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ /* * Do not modify this file. This file is generated from the aws-query-compatible-2012-11-05.normal.json service model. */ using System; using System.IO; using System.Linq; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; using Amazon.QueryCompatible; using Amazon.QueryCompatible.Model; using Amazon.QueryCompatible.Model.Internal.MarshallTransformations; using Amazon.Runtime.Internal.Transform; using ServiceClientGenerator; using AWSSDK_DotNet35.UnitTests.TestTools; namespace AWSSDK_DotNet35.UnitTests.Marshalling { [TestClass] public class QueryCompatibleMarshallingTests { static readonly ServiceModel service_model = Utils.LoadServiceModel("aws-query-compatible"); [TestMethod] [TestCategory("UnitTest")] [TestCategory("Json")] [TestCategory("QueryCompatible")] public void CreateQueueMarshallTest() { var request = InstantiateClassGenerator.Execute(); var marshaller = new CreateQueueRequestMarshaller(); var internalRequest = marshaller.Marshall(request); var jsonRequest = UTF8Encoding.UTF8.GetString(internalRequest.Content); Comparer.CompareObjectToJson(request,jsonRequest); var webResponse = new WebResponseData { Headers = { {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"} } }; var jsonResponse = new JsonSampleGenerator(service_model, service_model.FindOperation("CreateQueue").ResponseStructure).Execute(); webResponse.Headers.Add("Content-Length", UTF8Encoding.UTF8.GetBytes(jsonResponse).Length.ToString()); UnmarshallerContext context = new JsonUnmarshallerContext(Utils.CreateStreamFromString(jsonResponse), false, webResponse); var response = CreateQueueResponseUnmarshaller.Instance.Unmarshall(context) as CreateQueueResponse; InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Json")] [TestCategory("QueryCompatible")] public void CreateQueue_QueueDeletedRecentlyExceptionMarshallTest() { var operation = service_model.FindOperation("CreateQueue"); var request = InstantiateClassGenerator.Execute(); var marshaller = new CreateQueueRequestMarshaller(); var internalRequest = marshaller.Marshall(request); var jsonRequest = UTF8Encoding.UTF8.GetString(internalRequest.Content); Comparer.CompareObjectToJson(request,jsonRequest); var exception = operation.Exceptions.First(e => e.Name.Equals("QueueDeletedRecentlyException")); var jsonResponse = new JsonSampleGenerator(service_model, exception).Execute(); var webResponse = new WebResponseData { Headers = { {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"}, {"x-amzn-ErrorType","QueueDeletedRecentlyException"}, {"Content-Length", UTF8Encoding.UTF8.GetBytes(jsonResponse).Length.ToString()} } }; var context = new JsonUnmarshallerContext(Utils.CreateStreamFromString(jsonResponse), true, webResponse, true); var response = CreateQueueResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Json")] [TestCategory("QueryCompatible")] public void CreateQueue_QueueNameExistsExceptionMarshallTest() { var operation = service_model.FindOperation("CreateQueue"); var request = InstantiateClassGenerator.Execute(); var marshaller = new CreateQueueRequestMarshaller(); var internalRequest = marshaller.Marshall(request); var jsonRequest = UTF8Encoding.UTF8.GetString(internalRequest.Content); Comparer.CompareObjectToJson(request,jsonRequest); var exception = operation.Exceptions.First(e => e.Name.Equals("QueueNameExistsException")); var jsonResponse = new JsonSampleGenerator(service_model, exception).Execute(); var webResponse = new WebResponseData { Headers = { {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"}, {"x-amzn-ErrorType","QueueNameExistsException"}, {"Content-Length", UTF8Encoding.UTF8.GetBytes(jsonResponse).Length.ToString()} } }; var context = new JsonUnmarshallerContext(Utils.CreateStreamFromString(jsonResponse), true, webResponse, true); var response = CreateQueueResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } } }