コード例 #1
0
        private async Task Insert(TemplateViewModel email)
        {
            var httpResponse = await _client.PostAsync("/emails/templates",
                                                       new StringContent(email.ToJson(), Encoding.UTF8, MediaTypeNames.Application.Json));

            try
            {
                httpResponse.EnsureSuccessStatusCode();
            }
            catch
            {
                _output.WriteLine(await httpResponse.Content.ReadAsStringAsync());
                throw;
            }

            httpResponse.Headers.Location.Should().NotBeNull();
            httpResponse.Headers.Location.PathAndQuery.Should().Contain("/emails");
        }