Last active
December 15, 2025 13:32
-
-
Save pazteddy/2262a6186837c153475fdc8896407c31 to your computer and use it in GitHub Desktop.
Pruebas de integración para listado y cálculos de Orders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class OrderIntegrationTests : IAsyncLifetime | |
| { | |
| private CustomWebApplicationFactory _factory = null!; | |
| private HttpClient _httpClient = null!; | |
| public async Task InitializeAsync() | |
| { | |
| _factory = new CustomWebApplicationFactory(); | |
| _httpClient = _factory.GetHttpClient(); | |
| await Task.CompletedTask; | |
| } | |
| public async Task DisposeAsync() | |
| { | |
| _httpClient?.Dispose(); | |
| await _factory.DisposeAsync(); | |
| } | |
| [Fact(DisplayName = "GET /orders debe retornar 200 OK con lista de órdenes")] | |
| public async Task GetAllOrders_ReturnsOkWithList() | |
| { | |
| var response = await _httpClient.GetAsync("/orders"); | |
| response.StatusCode.Should().Be(HttpStatusCode.OK); | |
| response.Content.Headers.ContentType?.MediaType.Should().Be("application/json"); | |
| var orders = await response.Content.ReadFromJsonAsync<IEnumerable<OrderResponse>>(); | |
| orders.Should().NotBeNull(); | |
| orders.Should().NotBeEmpty(); | |
| } | |
| [Fact(DisplayName = "GET /orders retorna órdenes con datos completos")] | |
| public async Task GetAllOrders_ReturnsOrdersWithCompleteData() | |
| { | |
| var response = await _httpClient.GetAsync("/orders"); | |
| var orders = await response.Content.ReadFromJsonAsync<IEnumerable<OrderResponse>>(); | |
| response.StatusCode.Should().Be(HttpStatusCode.OK); | |
| orders.Should().AllSatisfy(order => | |
| { | |
| order.Id.Should().BeGreaterThan(0); | |
| order.OrderDate.Should().NotBe(default(DateTime)); | |
| order.CustomerName.Should().NotBeNullOrEmpty(); | |
| order.CustomerEmail.Should().NotBeNullOrEmpty(); | |
| order.ProductName.Should().NotBeNullOrEmpty(); | |
| order.UnitPrice.Should().BeGreaterThan(0); | |
| order.Quantity.Should().BeGreaterThan(0); | |
| order.Total.Should().BeGreaterThan(0); | |
| }); | |
| } | |
| [Fact(DisplayName = "GET /orders valida cálculo correcto del Total (UnitPrice × Quantity)", Skip = "Falta implementación")] | |
| public async Task GetAllOrders_CalculatesTotalCorrectly() | |
| { | |
| } | |
| [Fact(DisplayName = "GET /orders retorna las órdenes de forma consistente", Skip = "Falta implementación")] | |
| public async Task GetAllOrders_ReturnsConsistentResults() | |
| { | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment