public async Task PlaceOrder_Returns_A_List_Of_Validation_Errors_When_OrderNew_Model_Is_Not_Valid(OrderNew newOrder) { var response = await this.Client.PostAsync(Routes.Orders, newOrder.AsStringContent()); Assert.True(response.StatusCode == HttpStatusCode.BadRequest); var validationErrors = await response.GetFromBody <Dictionary <string, object> >(); Assert.NotNull(validationErrors); Assert.True(validationErrors.Keys.Count > 0); }
public async Task PlaceOrder_Fails_When_Attempt_To_Create_Order_With_Existing_OrderId() { var existingOrder = OrdersSeed.Orders.Value.FirstOrDefault(); Assert.NotNull(existingOrder); var newOrder = new OrderNew { CustomerName = "Ivan M", HouseNumber = 12, OrderId = existingOrder.OrderId, PostCode = "1673AO", Price = 20.0m }; var response = await this.Client.PostAsync(Routes.Orders, newOrder.AsStringContent()); Assert.True(response.StatusCode == HttpStatusCode.InternalServerError); var error = await response.GetFromBody <ExposableApiError>(); Assert.NotNull(error); Assert.True(!string.IsNullOrEmpty(error.Reason)); }