Implemented order service tests

This commit is contained in:
Khwezi Mngoma
2026-05-29 08:18:29 +02:00
parent 2546c34ffc
commit 4397976ed8
4 changed files with 37 additions and 6 deletions
@@ -114,54 +114,83 @@ public class OrderServiceFeatureTests(Fixture fixture) : IClassFixture<Fixture>
[IntegrationFact]
public async Task AddShippingToOrderAsync_ShouldReturn_ResultWithSuccess()
{
var request = new CreateShipping(1, 2);
var result = await orderService.AddShippingToOrderAsync(1, request, fixture.CancellationToken);
Assert.True(result.IsSuccess);
Assert.True(result.Value > 0);
}
[IntegrationFact]
public async Task UpdateShippingStatusAsync_ShouldReturn_ResultWithSuccess()
{
var result = await orderService.UpdateShippingStatusAsync(1, ShippingStatuses.Shipped, fixture.CancellationToken);
Assert.True(result.IsSuccess);
}
[IntegrationFact]
public async Task GetShippingByOrderIdAsync_ShouldReturn_ResultWithShipping()
{
var result = await orderService.GetShippingByOrderIdAsync(1, fixture.CancellationToken);
Assert.True(result.IsSuccess);
Assert.NotNull(result.Value);
}
[IntegrationFact]
public async Task RemoveShippingFromOrderAsync_ShouldReturn_ResultWithSuccess()
{
var result = await orderService.RemoveShippingFromOrderAsync(1, 1, fixture.CancellationToken);
Assert.True(result.IsSuccess);
}
[IntegrationFact]
public async Task UpdateShippingTrackingNumberAsync_ShouldReturn_ResultWithSuccess()
{
var result = await orderService.UpdateShippingTrackingNumberAsync(1, 2, "NA0009969397");
Assert.True(result.IsSuccess);
}
[IntegrationFact]
public async Task CreateShippingProviderAsync_ShouldReturn_ResultWithSuccess()
public async Task CreateShippingProviderAsync_ShouldReturn_ResultWithShippingProviderId()
{
var request = new CreateShippingProvider(ShippingProviderTypes.FastWay, "FastWay Couriers", 50, "https://www.fastway.co.za/our-services/track-your-parcel");
var result = await orderService.CreateShippingProviderAsync(request, fixture.CancellationToken);
Assert.True(result.IsSuccess);
Assert.True(result.Value > 0);
}
[IntegrationFact]
public async Task GetShippingProvidersAsync_ShouldReturn_ResultWithShippingProviderList()
{
var result = await orderService.GetShippingProvidersAsync(true, fixture.CancellationToken);
Assert.True(result.IsSuccess);
Assert.NotEmpty(result.Value);
}
[IntegrationFact]
public async Task GetShippingProviderAsync_ShouldReturn_ResultWithShippingProvider()
{
var result = await orderService.GetShippingProviderAsync(2, fixture.CancellationToken);
Assert.True(result.IsSuccess);
Assert.NotNull(result.Value);
}
[IntegrationFact]
public async Task UpdateShippingProviderAsync_ShouldReturn_ResultWithSuccess()
{
var request = new UpdateShippingProvider(2,true, "FastWay Couriers", 50, "https://www.fastway.co.za/our-services/track-your-parcel");
var result = await orderService.UpdateShippingProviderAsync(request, fixture.CancellationToken);
Assert.True(result.IsSuccess);
}
}