// ------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version: 17.0.0.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // // ------------------------------------------------------------------------------ namespace ServiceClientGenerator.Generators.TestFiles { using System.IO; using System.Linq; using System.Text; using System.Collections.Generic; using System; /// /// Class to produce the template output /// #line 1 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")] public partial class RestMarshallingTests : Generators.BaseGenerator { #line hidden /// /// Create the template output /// public override string TransformText() { #line 7 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" AddLicenseHeader(); #line default #line hidden this.Write("\r\n\r\nusing System;\r\nusing System.Globalization;\r\nusing System.IO;\r\nusing System.Li" + "nq;\r\nusing System.Text;\r\nusing Microsoft.VisualStudio.TestTools.UnitTesting;\r\n\r\n" + "using "); #line 19 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace)); #line default #line hidden this.Write(";\r\nusing "); #line 20 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace)); #line default #line hidden this.Write(".Model;\r\nusing "); #line 21 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace)); #line default #line hidden this.Write(@".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 "); #line 31 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.ClassName)); #line default #line hidden this.Write("MarshallingTests\r\n {\r\n static readonly ServiceModel service_model = Uti" + "ls.LoadServiceModel(\""); #line 33 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.ServiceDirectoryName)); #line default #line hidden this.Write("\");\r\n\t\t"); #line 34 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" foreach(var operation in this.Config.ServiceModel.Operations) { #line default #line hidden this.Write("\r\n [TestMethod]\r\n\t\t[TestCategory(\"UnitTest\")]\r\n\t\t[TestCategory(\""); #line 41 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.ServiceModel.Type)); #line default #line hidden this.Write("\")]\r\n\t\t[TestCategory(\""); #line 42 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.TestCategory)); #line default #line hidden this.Write("\")]\r\n public void "); #line 43 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("MarshallTest()\r\n {\r\n\t\t\tvar operation = service_model.FindOperation(\""); #line 45 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("\");\r\n\r\n var request = InstantiateClassGenerator.Execute<"); #line 47 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("Request>();\r\n var marshaller = new "); #line 48 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("RequestMarshaller();\r\n\r\n var internalRequest = marshaller.Marshall(req" + "uest);\r\n TestTools.RequestValidator.Validate(\""); #line 51 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("\", request, internalRequest, service_model);\r\n\r\n"); #line 53 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" if (operation.RequestHeaderMembers.Count(m => m.Shape.IsMap) > 0) { foreach (var member in operation.RequestHeaderMembers) { if (member.Shape.IsMap) { #line default #line hidden this.Write(" // Validate request headers in "); #line 61 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(" (prefix \'"); #line 61 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("\')\r\n foreach (var kvp"); #line 62 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(" in request."); #line 62 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(")\r\n {\r\n"); #line 64 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" // Dictionary if (member.ModelShape.ValueShape.IsString) { #line default #line hidden this.Write(" Assert.AreEqual(kvp"); #line 69 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Value, internalRequest.Headers[$\""); #line 69 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("{kvp"); #line 69 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Key}\"]);\r\n"); #line 70 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } // Dictionary> else if (member.ModelShape.ValueShape?.ListShape?.IsString == true) { #line default #line hidden this.Write(" var flattenedHeader = string.Join(\",\", kvp"); #line 76 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Value);\r\n\r\n Assert.AreEqual(flattenedHeader, internalRequest.Head" + "ers[$\""); #line 78 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("{kvp"); #line 78 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Key}\"]);\r\n"); #line 79 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } #line default #line hidden this.Write(" }\r\n"); #line 83 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } } } #line default #line hidden #line 88 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" if(operation.ResponseStructure != null) { #line default #line hidden this.Write("\t\t\tvar webResponse = new WebResponseData\r\n\t\t\t{\r\n\t\t\t\tHeaders = {\r\n"); #line 95 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" if (operation.ResponseHeaderMembers.Count() > 0 ) { foreach (var member in operation.ResponseHeaderMembers) { if (member.Shape.IsString) { if (member.IsJsonValue) { #line default #line hidden this.Write("\t\t\t\t\t{\""); #line 106 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("\",Convert.ToBase64String(Encoding.UTF8.GetBytes(\""); #line 106 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("_Value\"))},\r\n"); #line 107 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } else { #line default #line hidden this.Write("\t\t\t\t\t{\""); #line 112 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("\",\""); #line 112 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("_Value\"},\r\n"); #line 113 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } } else if (member.Shape.IsMap) { //Defer processing of the map until after the other types because //we cannot write the code to write out the dynamic map statically //inline. continue; } else if (member.Shape.IsInt) { #line default #line hidden this.Write("\t\t\t\t\t{\""); #line 126 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("\",int.MaxValue.ToString(CultureInfo.InvariantCulture)},\r\n"); #line 127 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } else if (member.Shape.IsLong) { #line default #line hidden this.Write("\t\t\t\t\t{\""); #line 132 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("\",long.MaxValue.ToString(CultureInfo.InvariantCulture)},\r\n"); #line 133 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } else if (member.Shape.IsDateTime) { #line default #line hidden this.Write("\t\t\t\t\t{\""); #line 138 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("\",ValidatorUtils.GetTestDate(TimestampFormat."); #line 138 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.TimestampFormat)); #line default #line hidden this.Write(")},\r\n"); #line 139 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } else { throw new Exception("Member " + member.Shape.Name + " cannot be handled because it's type, " + member.Shape.Type + ", is not handled. Please Update RestMarshallingTests.tt."); } } } #line default #line hidden this.Write("\t\t\t\t\t{\"x-amzn-RequestId\", Guid.NewGuid().ToString()},\r\n\t\t\t\t\t{\"x-amz-crc32\",\"0\"}\r\n" + "\t\t\t\t}\r\n\t\t\t};\r\n"); #line 151 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" if (operation.ResponseHeaderMembers.Count(m => m.Shape.IsMap) > 0) { #line default #line hidden this.Write("\r\n // populate a dummy response object so we can copy the headers\r\n " + " var dummyResponse = InstantiateClassGenerator.Execute<"); #line 157 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("Response>();\r\n\r\n"); #line 159 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" foreach (var member in operation.ResponseHeaderMembers) { if (member.Shape.IsMap) { #line default #line hidden this.Write(" // Populate map of response headers for "); #line 165 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(" with prefix \""); #line 165 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("\".\r\n foreach (var kvp"); #line 166 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(" in dummyResponse."); #line 166 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(")\r\n {\r\n"); #line 168 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" // Dictionary if (member.ModelShape.ValueShape.IsString) { #line default #line hidden this.Write(" webResponse.Headers.Add($\""); #line 173 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("{kvp"); #line 173 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Key}\", kvp"); #line 173 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Value);\r\n"); #line 174 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } // Dictionary> else if (member.ModelShape.ValueShape?.ListShape?.IsString == true) { #line default #line hidden this.Write(" webResponse.Headers.Add($\""); #line 180 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("{kvp"); #line 180 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Key}\", string.Join(\",\", kvp"); #line 180 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Value.ToArray()));\r\n"); #line 181 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } #line default #line hidden this.Write(" }\r\n"); #line 185 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } } } if(this.Config.ServiceModel.Type == ServiceType.Rest_Xml) { #line default #line hidden this.Write(@" var payloadResponse = new XmlSampleGenerator(service_model, operation).Execute(); webResponse.ContentLength = payloadResponse.Length; var context = new XmlUnmarshallerContext(Utils.CreateStreamFromString(payloadResponse), false, webResponse); ResponseUnmarshaller unmarshaller = "); #line 197 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("ResponseUnmarshaller.Instance;\r\n var response = unmarshaller.Unmarshal" + "l(context) as "); #line 198 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("Response;\r\n InstantiateClassGenerator.ValidateObjectFullyInstantiated(" + "response);\r\n"); #line 200 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } else { #line default #line hidden this.Write(@" 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 = "); #line 209 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("ResponseUnmarshaller.Instance;\r\n var response = unmarshaller.Unmarshal" + "l(context) as "); #line 210 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("Response;\r\n InstantiateClassGenerator.ValidateObjectFullyInstantiated(" + "response);\r\n"); #line 212 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" if (operation.ResponseHeaderMembers.Count(m => m.Shape.IsMap) > 0) { foreach (var member in operation.ResponseHeaderMembers) { if (member.Shape.IsMap) { #line default #line hidden this.Write(" // Validate response headers for "); #line 220 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(" with prefix \""); #line 220 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("\".\r\n foreach (var kvp"); #line 221 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(" in dummyResponse."); #line 221 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(")\r\n {\r\n"); #line 223 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" // Dictionary if (member.ModelShape.ValueShape.IsString) { #line default #line hidden this.Write(" Assert.AreEqual(response.ResponseHeaders[kvp"); #line 228 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Key], kvp"); #line 228 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Value);\r\n"); #line 229 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } // Dictionary> else if (member.ModelShape.ValueShape?.ListShape?.IsString == true) { #line default #line hidden this.Write(" Assert.AreEqual(response.ResponseHeaders[kvp"); #line 235 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Key].Count(), kvp"); #line 235 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Value.Count());\r\n\r\n for (var i = 0; i < response.ResponseHeaders[" + "kvp"); #line 237 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Key].Count(); i++)\r\n Assert.AreEqual(response.ResponseHeaders" + "[kvp"); #line 238 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Key][i], kvp"); #line 238 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Value[i]);\r\n"); #line 239 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } #line default #line hidden this.Write(" }\r\n"); #line 243 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } } } } } #line default #line hidden this.Write(" }\r\n"); #line 251 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" foreach (var exception in operation.Exceptions) { #line default #line hidden this.Write("\r\n [TestMethod]\r\n [TestCategory(\"UnitTest\")]\r\n [TestCategory" + "(\""); #line 258 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.ServiceModel.Type)); #line default #line hidden this.Write("\")]\r\n [TestCategory(\""); #line 259 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.TestCategory)); #line default #line hidden this.Write("\")]\r\n public void "); #line 260 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("_"); #line 260 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exception.Name)); #line default #line hidden this.Write("MarshallTest()\r\n {\r\n var operation = service_model.FindOperatio" + "n(\""); #line 262 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("\");\r\n\r\n var request = InstantiateClassGenerator.Execute<"); #line 264 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("Request>();\r\n var marshaller = new "); #line 265 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("RequestMarshaller();\r\n var internalRequest = marshaller.Marshall(reque" + "st);\r\n\r\n TestTools.RequestValidator.Validate(\""); #line 268 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("\", request, internalRequest, service_model);\r\n\r\n var exception = opera" + "tion.Exceptions.First(e => e.Name.Equals(\""); #line 270 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exception.Name)); #line default #line hidden this.Write("\"));\r\n var webResponse = new WebResponseData\r\n {\r\n " + " Headers = {\r\n"); #line 274 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" if( operation.ResponseHeaderMembers.Count() > 0 ) { foreach (var member in operation.ResponseHeaderMembers) { if (member.Shape.IsString) { if (member.IsJsonValue) { #line default #line hidden this.Write(" {\""); #line 284 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("\",Convert.ToBase64String(Encoding.UTF8.GetBytes(\""); #line 284 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("_Value\"))},\r\n"); #line 285 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } else { #line default #line hidden this.Write(" {\""); #line 290 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("\",\""); #line 290 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("_Value\"},\r\n"); #line 291 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } } else if (member.Shape.IsMap) { //Defer processing of the map until after the other types because //we cannot write the code to write out the dynamic map statically //inline. continue; } else if (member.Shape.IsInt) { #line default #line hidden this.Write(" {\""); #line 305 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("\",int.MaxValue.ToString(CultureInfo.InvariantCulture)},\r\n"); #line 306 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } else if (member.Shape.IsLong) { #line default #line hidden this.Write(" {\""); #line 311 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("\",long.MaxValue.ToString(CultureInfo.InvariantCulture)},\r\n"); #line 312 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } else if (member.Shape.IsDateTime) { #line default #line hidden this.Write(" {\""); #line 317 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("\",ValidatorUtils.GetTestDate(TimestampFormat."); #line 317 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.TimestampFormat)); #line default #line hidden this.Write(")},\r\n"); #line 318 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } else { throw new Exception("Member " + member.Shape.Name + " cannot be handled because it's type, " + member.Shape.Type + ", is not handled. Please Update RestMarshallingTests.tt."); } } } #line default #line hidden this.Write(" {\"x-amzn-RequestId\", Guid.NewGuid().ToString()},\r\n " + " {\"x-amz-crc32\",\"0\"},\r\n"); #line 329 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" if(this.Config.ServiceModel.Type != ServiceType.Rest_Xml) { #line default #line hidden this.Write(" {\"x-amzn-ErrorType\",\""); #line 333 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(exception.Name)); #line default #line hidden this.Write("\"},\r\n"); #line 334 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } #line default #line hidden this.Write(" }\r\n };\r\n\r\n"); #line 340 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" if (operation.ResponseHeaderMembers.Count(m => m.Shape.IsMap) > 0) { #line default #line hidden this.Write(" // populate a dummy response object so we can copy the headers\r\n " + " var dummyResponse = InstantiateClassGenerator.Execute<"); #line 345 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("Response>();\r\n"); #line 346 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" foreach (var member in operation.ResponseHeaderMembers) { if (member.Shape.IsMap) { #line default #line hidden this.Write(" // Populate map of response headers for "); #line 353 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(" with prefix \""); #line 353 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("\".\r\n foreach (var kvp"); #line 354 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(" in dummyResponse."); #line 354 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(")\r\n {\r\n"); #line 356 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" // Dictionary if (member.ModelShape.ValueShape.IsString) { #line default #line hidden this.Write(" webResponse.Headers.Add($\""); #line 361 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("{kvp"); #line 361 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Key}\", kvp"); #line 361 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Value);\r\n"); #line 362 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } // Dictionary> else if (member.ModelShape.ValueShape?.ListShape?.IsString == true) { #line default #line hidden this.Write(" webResponse.Headers.Add($\""); #line 368 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallLocationName)); #line default #line hidden this.Write("{kvp"); #line 368 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Key}\", string.Join(\",\", kvp"); #line 368 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName)); #line default #line hidden this.Write(".Value.ToArray()));\r\n"); #line 369 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } #line default #line hidden this.Write(" }\r\n\r\n"); #line 374 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } } } if(this.Config.ServiceModel.Type == ServiceType.Rest_Xml) { #line default #line hidden this.Write(@" var payloadResponse = new XmlSampleGenerator(service_model, operation).Execute(exception); webResponse.Headers[""Content-Length""] = UTF8Encoding.UTF8.GetBytes(payloadResponse).Length.ToString(); var context = new XmlUnmarshallerContext(Utils.CreateStreamFromString(payloadResponse), true, webResponse, true); var response = "); #line 385 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("ResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpS" + "tatusCode.OK);\r\n\r\n InstantiateClassGenerator.ValidateObjectFullyInsta" + "ntiated(response);\r\n"); #line 388 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } else { #line default #line hidden this.Write(@" 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 = "); #line 396 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" this.Write(this.ToStringHelper.ToStringWithCulture(operation.Name)); #line default #line hidden this.Write("ResponseUnmarshaller.Instance.UnmarshallException(context, null, System.Net.HttpS" + "tatusCode.OK);\r\n\r\n InstantiateClassGenerator.ValidateObjectFullyInsta" + "ntiated(response);\r\n"); #line 399 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } #line default #line hidden this.Write(" }\r\n"); #line 403 "C:\projects\aws\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\TestFiles\RestMarshallingTests.tt" } } #line default #line hidden this.Write(" }\r\n}"); return this.GenerationEnvironment.ToString(); } } #line default #line hidden }