public async void When_CartLine_Is_Added_Expect_Created_StatusCode_And_Added_Entity() { //Arrange var product = _fixture.GenerateProduct(); var content = new StringContent(JsonConvert.SerializeObject(new AddCartLineDTO() { Amount = 10, ProductId = product.Id }), Encoding.UTF8, "application/json"); //Act var response = await _fixture.Client.PostAsync("api/cart", content); //Assert Assert.Equal(HttpStatusCode.Created, response.StatusCode); var result = await response.Content.ReadAsStringAsync(); var viewModel = JsonConvert.DeserializeObject <CartLineViewModel>(result); Assert.NotEqual(0, viewModel.Id); var entity = await _fixture.Context.CartLines.FindAsync(viewModel.Id); Assert.NotNull(entity); Assert.Equal(10, entity.Amount); }