public async Task ChangeCustomerName_ShouldReturn_Ok(ChangeNameCustomerCommand request) { var readModelContext = (ReadModelDbContext)_fixture.Services.GetService(typeof(ReadModelDbContext)); var customer = await readModelContext.Customers.FirstOrDefaultAsync(); var response = await _client.PutRequestAsStringContent($"/customers/{customer.Id}", request); response.EnsureSuccessStatusCode(); var content = await response.Content.ReadAsStringAsync(); content.ShouldNotBeEmpty(); _output.WriteLine(content); var jsonObject = JObject.Parse(content); jsonObject.ShouldContainKeyAndValue("id", customer.Id.ToString()); jsonObject.ShouldContainKeyAndValue("username", customer.Username); jsonObject.ShouldContainKeyAndValue("firstName", request.FirstName); jsonObject.ShouldContainKeyAndValue("lastName", request.LastName); }
public async Task ChangeCustomerName_WithInvalidCommand_ShouldReturn_BadRequest(ChangeNameCustomerCommand request) { var readModelContext = (ReadModelDbContext)_fixture.Services.GetService(typeof(ReadModelDbContext)); var customer = await readModelContext.Customers.FirstOrDefaultAsync(); var response = await _client.PutRequestAsStringContent($"/customers/{customer.Id}", request); response.IsSuccessStatusCode.ShouldBeFalse(); response.StatusCode.ShouldBe(System.Net.HttpStatusCode.BadRequest); var content = await response.Content.ReadAsStringAsync(); content.ShouldNotBeEmpty(); _output.WriteLine(content); }