示例#1
0
        public async Task PostEndpoints()
        {
            string uri    = "/customer";
            var    client = _factory.CreateClient();

            var command = new CreateCustomerCommand
            {
                FirstName    = "Herbert",
                LastName     = "Scrackle",
                EmailAddress = "*****@*****.**"
            };

            var httpContent = command.ToHttpContent(_mediaType);

            var response = await client.PostAsync(uri, httpContent).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();
            response.Content.Headers.ContentType.ToString().Should().StartWith(_mediaType);

            var theDto = response.Content.ReadAsJsonAsync <CustomerDto>();

            theDto.Id.Should().BeGreaterThan(0);
        }