/* * 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 mediastore-data-2017-09-01.normal.json service model. */ using System; using System.Globalization; using System.IO; using System.Linq; using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; using Amazon.MediaStoreData; using Amazon.MediaStoreData.Model; using Amazon.MediaStoreData.Model.Internal.MarshallTransformations; using Amazon.Runtime.Internal.Transform; using Amazon.Util; using ServiceClientGenerator; using AWSSDK_DotNet35.UnitTests.TestTools; namespace AWSSDK_DotNet35.UnitTests.Marshalling { [TestClass] public partial class MediaStoreDataMarshallingTests { static readonly ServiceModel service_model = Utils.LoadServiceModel("mediastore-data"); [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void DeleteObjectMarshallTest() { var operation = service_model.FindOperation("DeleteObject"); var request = InstantiateClassGenerator.Execute(); var marshaller = new DeleteObjectRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("DeleteObject", 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 = DeleteObjectResponseUnmarshaller.Instance; var response = unmarshaller.Unmarshall(context) as DeleteObjectResponse; InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void DeleteObject_ContainerNotFoundExceptionMarshallTest() { var operation = service_model.FindOperation("DeleteObject"); var request = InstantiateClassGenerator.Execute(); var marshaller = new DeleteObjectRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("DeleteObject", request, internalRequest, service_model); var exception = operation.Exceptions.First(e => e.Name.Equals("ContainerNotFoundException")); var webResponse = new WebResponseData { Headers = { {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"}, {"x-amzn-ErrorType","ContainerNotFoundException"}, } }; 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 = DeleteObjectResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void DeleteObject_InternalServerErrorExceptionMarshallTest() { var operation = service_model.FindOperation("DeleteObject"); var request = InstantiateClassGenerator.Execute(); var marshaller = new DeleteObjectRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("DeleteObject", request, internalRequest, service_model); var exception = operation.Exceptions.First(e => e.Name.Equals("InternalServerErrorException")); var webResponse = new WebResponseData { Headers = { {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"}, {"x-amzn-ErrorType","InternalServerErrorException"}, } }; 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 = DeleteObjectResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void DeleteObject_ObjectNotFoundExceptionMarshallTest() { var operation = service_model.FindOperation("DeleteObject"); var request = InstantiateClassGenerator.Execute(); var marshaller = new DeleteObjectRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("DeleteObject", request, internalRequest, service_model); var exception = operation.Exceptions.First(e => e.Name.Equals("ObjectNotFoundException")); var webResponse = new WebResponseData { Headers = { {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"}, {"x-amzn-ErrorType","ObjectNotFoundException"}, } }; 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 = DeleteObjectResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void DescribeObjectMarshallTest() { var operation = service_model.FindOperation("DescribeObject"); var request = InstantiateClassGenerator.Execute(); var marshaller = new DescribeObjectRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("DescribeObject", request, internalRequest, service_model); var webResponse = new WebResponseData { Headers = { {"Cache-Control","Cache-Control_Value"}, {"Content-Length",long.MaxValue.ToString(CultureInfo.InvariantCulture)}, {"Content-Type","Content-Type_Value"}, {"ETag","ETag_Value"}, {"Last-Modified",ValidatorUtils.GetTestDate(TimestampFormat.RFC822)}, {"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 = DescribeObjectResponseUnmarshaller.Instance; var response = unmarshaller.Unmarshall(context) as DescribeObjectResponse; InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void DescribeObject_ContainerNotFoundExceptionMarshallTest() { var operation = service_model.FindOperation("DescribeObject"); var request = InstantiateClassGenerator.Execute(); var marshaller = new DescribeObjectRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("DescribeObject", request, internalRequest, service_model); var exception = operation.Exceptions.First(e => e.Name.Equals("ContainerNotFoundException")); var webResponse = new WebResponseData { Headers = { {"Cache-Control","Cache-Control_Value"}, {"Content-Length",long.MaxValue.ToString(CultureInfo.InvariantCulture)}, {"Content-Type","Content-Type_Value"}, {"ETag","ETag_Value"}, {"Last-Modified",ValidatorUtils.GetTestDate(TimestampFormat.RFC822)}, {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"}, {"x-amzn-ErrorType","ContainerNotFoundException"}, } }; 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 = DescribeObjectResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void DescribeObject_InternalServerErrorExceptionMarshallTest() { var operation = service_model.FindOperation("DescribeObject"); var request = InstantiateClassGenerator.Execute(); var marshaller = new DescribeObjectRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("DescribeObject", request, internalRequest, service_model); var exception = operation.Exceptions.First(e => e.Name.Equals("InternalServerErrorException")); var webResponse = new WebResponseData { Headers = { {"Cache-Control","Cache-Control_Value"}, {"Content-Length",long.MaxValue.ToString(CultureInfo.InvariantCulture)}, {"Content-Type","Content-Type_Value"}, {"ETag","ETag_Value"}, {"Last-Modified",ValidatorUtils.GetTestDate(TimestampFormat.RFC822)}, {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"}, {"x-amzn-ErrorType","InternalServerErrorException"}, } }; 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 = DescribeObjectResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void DescribeObject_ObjectNotFoundExceptionMarshallTest() { var operation = service_model.FindOperation("DescribeObject"); var request = InstantiateClassGenerator.Execute(); var marshaller = new DescribeObjectRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("DescribeObject", request, internalRequest, service_model); var exception = operation.Exceptions.First(e => e.Name.Equals("ObjectNotFoundException")); var webResponse = new WebResponseData { Headers = { {"Cache-Control","Cache-Control_Value"}, {"Content-Length",long.MaxValue.ToString(CultureInfo.InvariantCulture)}, {"Content-Type","Content-Type_Value"}, {"ETag","ETag_Value"}, {"Last-Modified",ValidatorUtils.GetTestDate(TimestampFormat.RFC822)}, {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"}, {"x-amzn-ErrorType","ObjectNotFoundException"}, } }; 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 = DescribeObjectResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void GetObjectMarshallTest() { var operation = service_model.FindOperation("GetObject"); var request = InstantiateClassGenerator.Execute(); var marshaller = new GetObjectRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("GetObject", request, internalRequest, service_model); var webResponse = new WebResponseData { Headers = { {"Cache-Control","Cache-Control_Value"}, {"Content-Length",long.MaxValue.ToString(CultureInfo.InvariantCulture)}, {"Content-Range","Content-Range_Value"}, {"Content-Type","Content-Type_Value"}, {"ETag","ETag_Value"}, {"Last-Modified",ValidatorUtils.GetTestDate(TimestampFormat.RFC822)}, {"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 = GetObjectResponseUnmarshaller.Instance; var response = unmarshaller.Unmarshall(context) as GetObjectResponse; InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void GetObject_ContainerNotFoundExceptionMarshallTest() { var operation = service_model.FindOperation("GetObject"); var request = InstantiateClassGenerator.Execute(); var marshaller = new GetObjectRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("GetObject", request, internalRequest, service_model); var exception = operation.Exceptions.First(e => e.Name.Equals("ContainerNotFoundException")); var webResponse = new WebResponseData { Headers = { {"Cache-Control","Cache-Control_Value"}, {"Content-Length",long.MaxValue.ToString(CultureInfo.InvariantCulture)}, {"Content-Range","Content-Range_Value"}, {"Content-Type","Content-Type_Value"}, {"ETag","ETag_Value"}, {"Last-Modified",ValidatorUtils.GetTestDate(TimestampFormat.RFC822)}, {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"}, {"x-amzn-ErrorType","ContainerNotFoundException"}, } }; 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 = GetObjectResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void GetObject_InternalServerErrorExceptionMarshallTest() { var operation = service_model.FindOperation("GetObject"); var request = InstantiateClassGenerator.Execute(); var marshaller = new GetObjectRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("GetObject", request, internalRequest, service_model); var exception = operation.Exceptions.First(e => e.Name.Equals("InternalServerErrorException")); var webResponse = new WebResponseData { Headers = { {"Cache-Control","Cache-Control_Value"}, {"Content-Length",long.MaxValue.ToString(CultureInfo.InvariantCulture)}, {"Content-Range","Content-Range_Value"}, {"Content-Type","Content-Type_Value"}, {"ETag","ETag_Value"}, {"Last-Modified",ValidatorUtils.GetTestDate(TimestampFormat.RFC822)}, {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"}, {"x-amzn-ErrorType","InternalServerErrorException"}, } }; 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 = GetObjectResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void GetObject_ObjectNotFoundExceptionMarshallTest() { var operation = service_model.FindOperation("GetObject"); var request = InstantiateClassGenerator.Execute(); var marshaller = new GetObjectRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("GetObject", request, internalRequest, service_model); var exception = operation.Exceptions.First(e => e.Name.Equals("ObjectNotFoundException")); var webResponse = new WebResponseData { Headers = { {"Cache-Control","Cache-Control_Value"}, {"Content-Length",long.MaxValue.ToString(CultureInfo.InvariantCulture)}, {"Content-Range","Content-Range_Value"}, {"Content-Type","Content-Type_Value"}, {"ETag","ETag_Value"}, {"Last-Modified",ValidatorUtils.GetTestDate(TimestampFormat.RFC822)}, {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"}, {"x-amzn-ErrorType","ObjectNotFoundException"}, } }; 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 = GetObjectResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void GetObject_RequestedRangeNotSatisfiableExceptionMarshallTest() { var operation = service_model.FindOperation("GetObject"); var request = InstantiateClassGenerator.Execute(); var marshaller = new GetObjectRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("GetObject", request, internalRequest, service_model); var exception = operation.Exceptions.First(e => e.Name.Equals("RequestedRangeNotSatisfiableException")); var webResponse = new WebResponseData { Headers = { {"Cache-Control","Cache-Control_Value"}, {"Content-Length",long.MaxValue.ToString(CultureInfo.InvariantCulture)}, {"Content-Range","Content-Range_Value"}, {"Content-Type","Content-Type_Value"}, {"ETag","ETag_Value"}, {"Last-Modified",ValidatorUtils.GetTestDate(TimestampFormat.RFC822)}, {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"}, {"x-amzn-ErrorType","RequestedRangeNotSatisfiableException"}, } }; 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 = GetObjectResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void ListItemsMarshallTest() { var operation = service_model.FindOperation("ListItems"); var request = InstantiateClassGenerator.Execute(); var marshaller = new ListItemsRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("ListItems", 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 = ListItemsResponseUnmarshaller.Instance; var response = unmarshaller.Unmarshall(context) as ListItemsResponse; InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void ListItems_ContainerNotFoundExceptionMarshallTest() { var operation = service_model.FindOperation("ListItems"); var request = InstantiateClassGenerator.Execute(); var marshaller = new ListItemsRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("ListItems", request, internalRequest, service_model); var exception = operation.Exceptions.First(e => e.Name.Equals("ContainerNotFoundException")); var webResponse = new WebResponseData { Headers = { {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"}, {"x-amzn-ErrorType","ContainerNotFoundException"}, } }; 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 = ListItemsResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void ListItems_InternalServerErrorExceptionMarshallTest() { var operation = service_model.FindOperation("ListItems"); var request = InstantiateClassGenerator.Execute(); var marshaller = new ListItemsRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("ListItems", request, internalRequest, service_model); var exception = operation.Exceptions.First(e => e.Name.Equals("InternalServerErrorException")); var webResponse = new WebResponseData { Headers = { {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"}, {"x-amzn-ErrorType","InternalServerErrorException"}, } }; 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 = ListItemsResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void PutObjectMarshallTest() { var operation = service_model.FindOperation("PutObject"); var request = InstantiateClassGenerator.Execute(); var marshaller = new PutObjectRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("PutObject", 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 = PutObjectResponseUnmarshaller.Instance; var response = unmarshaller.Unmarshall(context) as PutObjectResponse; InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void PutObject_ContainerNotFoundExceptionMarshallTest() { var operation = service_model.FindOperation("PutObject"); var request = InstantiateClassGenerator.Execute(); var marshaller = new PutObjectRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("PutObject", request, internalRequest, service_model); var exception = operation.Exceptions.First(e => e.Name.Equals("ContainerNotFoundException")); var webResponse = new WebResponseData { Headers = { {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"}, {"x-amzn-ErrorType","ContainerNotFoundException"}, } }; 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 = PutObjectResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } [TestMethod] [TestCategory("UnitTest")] [TestCategory("Rest_Json")] [TestCategory("MediaStoreData")] public void PutObject_InternalServerErrorExceptionMarshallTest() { var operation = service_model.FindOperation("PutObject"); var request = InstantiateClassGenerator.Execute(); var marshaller = new PutObjectRequestMarshaller(); var internalRequest = marshaller.Marshall(request); TestTools.RequestValidator.Validate("PutObject", request, internalRequest, service_model); var exception = operation.Exceptions.First(e => e.Name.Equals("InternalServerErrorException")); var webResponse = new WebResponseData { Headers = { {"x-amzn-RequestId", Guid.NewGuid().ToString()}, {"x-amz-crc32","0"}, {"x-amzn-ErrorType","InternalServerErrorException"}, } }; 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 = PutObjectResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpStatusCode.OK); InstantiateClassGenerator.ValidateObjectFullyInstantiated(response); } } }