public async Task TestGetErrorCode_knownErrorCodeAsync()
 {
     using (HttpResponseMessage httpResponseException = new HttpResponseMessage(HttpStatusCode.BadRequest)
     {
         Content = new StringContent("{\"errors\":[{\"code\":\"MANIFEST_INVALID\",\"message\":\"manifest invalid\",\"detail\":{}}]}")
     })
     {
         Assert.AreEqual(
             ErrorCode.ManifestInvalid, await ErrorResponseUtil.GetErrorCodeAsync(httpResponseException).ConfigureAwait(false));
     }
 }
        public async Task TestGetErrorCode_invalidErrorObjectAsync()
        {
            using (HttpResponseMessage httpResponseException = new HttpResponseMessage(HttpStatusCode.BadRequest)
            {
                Content = new StringContent("{\"type\":\"other\",\"message\":\"some other object\"}")
            })
            {
                try
                {
                    await ErrorResponseUtil.GetErrorCodeAsync(httpResponseException).ConfigureAwait(false);

                    Assert.Fail();
                }
                catch (HttpResponseException ex)
                {
                    Assert.AreSame(httpResponseException, ex.Cause);
                }
            }
        }
        public async Task TestGetErrorCode_unknownErrorCodeAsync()
        {
            using (HttpResponseMessage httpResponseException = new HttpResponseMessage(HttpStatusCode.BadRequest)
            {
                Content = new StringContent(
                    "{\"errors\":[{\"code\":\"INVALID_ERROR_CODE\",\"message\":\"invalid code\",\"detail\":{}}]}")
            })
            {
                try
                {
                    await ErrorResponseUtil.GetErrorCodeAsync(httpResponseException).ConfigureAwait(false);

                    Assert.Fail();
                }
                catch (HttpResponseException ex)
                {
                    Assert.AreSame(httpResponseException, ex.Cause);
                }
            }
        }
        public async Task TestGetErrorCode_multipleErrorsAsync()
        {
            using (HttpResponseMessage httpResponseException = new HttpResponseMessage(HttpStatusCode.BadRequest)
            {
                Content = new StringContent(
                    "{\"errors\":["
                    + "{\"code\":\"MANIFEST_INVALID\",\"message\":\"message 1\",\"detail\":{}},"
                    + "{\"code\":\"TAG_INVALID\",\"message\":\"message 2\",\"detail\":{}}"
                    + "]}")
            })
            {
                try
                {
                    await ErrorResponseUtil.GetErrorCodeAsync(httpResponseException).ConfigureAwait(false);

                    Assert.Fail();
                }
                catch (HttpResponseException ex)
                {
                    Assert.AreSame(httpResponseException, ex.Cause);
                }
            }
        }