using System; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; using Amazon.S3; using AWSSDK_DotNet.IntegrationTests.Utils; using Amazon; using Amazon.Runtime; using System.Collections.Generic; using System.Reflection; using Amazon.Runtime.Internal.Auth; using System.Configuration; using System.Collections.Specialized; using System.Xml; namespace AWSSDK_DotNet.IntegrationTests.Tests { [TestClass] public class Tests45 { [TestMethod] [TestCategory("General")] public void TestResponseMockingLots() { var count = 1000; for(int i=0;i { // create HttpResponse (in this case, from the raw response, but can be created manually) var httpResponse = Mocker.CreateHttpResponse(rawResponse); // modify headers httpResponse.Headers["x-amzn-RequestId"] = "foo!"; httpResponse.Headers.Remove("x-amz-crc32"); // modify body var json = ThirdParty.Json.LitJson.JsonMapper.ToObject(httpResponse.Body); var tableNames = json["TableNames"]; tableNames.Clear(); tableNames.Add("Logs"); httpResponse.Body = json.ToJson(); return httpResponse; }; // make calls and verify data is as expected response = client.ListTables(); Assert.IsNotNull(response); Assert.IsNotNull(response.TableNames); Assert.AreEqual(1, response.TableNames.Count); Assert.AreEqual("Logs", response.TableNames[0]); Assert.IsNotNull(response.ResponseMetadata); Assert.IsNotNull(response.ResponseMetadata.RequestId); Assert.AreEqual("foo!", response.ResponseMetadata.RequestId); // clear callback mocker.CreateResponseCallback = null; // set raw response to error response mocker.RawResponse = rawErrorResponse; // make call and verify exception is thrown var exception = AssertExtensions.ExpectException(() => client.DescribeTable("foo")); Assert.IsNotNull(exception); Assert.IsNotNull(exception.Message); Assert.AreEqual("Requested resource not found: Table: FakeTable not found", exception.Message); Assert.AreEqual("2222222222222222222222222222222222222222222222222222", exception.RequestId); } } } }