From 5e084ab0a8c5499d98c3641ea762d380a203b2fe Mon Sep 17 00:00:00 2001 From: ThompsonNye Date: Tue, 24 Jun 2025 20:01:45 +0200 Subject: [PATCH] Fix recurring mock data Reusing the faker instance like I used to seems to (suddenly?!) result in the same data, which newly results in a conflict response --- .../Vegasco.Server.Api.Tests.Integration/CarFaker.cs | 8 ++++---- .../ConsumptionFaker.cs | 11 +++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/tests/Vegasco.Server.Api.Tests.Integration/CarFaker.cs b/tests/Vegasco.Server.Api.Tests.Integration/CarFaker.cs index c562d15..0c21d4d 100644 --- a/tests/Vegasco.Server.Api.Tests.Integration/CarFaker.cs +++ b/tests/Vegasco.Server.Api.Tests.Integration/CarFaker.cs @@ -5,15 +5,15 @@ namespace Vegasco.Server.Api.Tests.Integration; internal class CarFaker { - private readonly Faker _faker = new(); - internal CreateCar.Request CreateCarRequest() { - return new CreateCar.Request(_faker.Person.FirstName); + Faker faker = new(); + return new CreateCar.Request(faker.Person.FirstName); } internal UpdateCar.Request UpdateCarRequest() { - return new UpdateCar.Request(_faker.Person.FirstName); + Faker faker = new(); + return new UpdateCar.Request(faker.Person.FirstName); } } \ No newline at end of file diff --git a/tests/Vegasco.Server.Api.Tests.Integration/ConsumptionFaker.cs b/tests/Vegasco.Server.Api.Tests.Integration/ConsumptionFaker.cs index 36aece2..36747c0 100644 --- a/tests/Vegasco.Server.Api.Tests.Integration/ConsumptionFaker.cs +++ b/tests/Vegasco.Server.Api.Tests.Integration/ConsumptionFaker.cs @@ -5,20 +5,19 @@ namespace Vegasco.Server.Api.Tests.Integration; internal class ConsumptionFaker { - private readonly Faker _faker = new(); - internal CreateConsumption.Request CreateConsumptionRequest(Guid carId) { + Faker faker = new(); return new CreateConsumption.Request( - _faker.Date.RecentOffset(), - _faker.Random.Int(1, 1_000), - _faker.Random.Int(20, 70), + faker.Date.RecentOffset(), + faker.Random.Int(1, 1_000), + faker.Random.Int(20, 70), carId); } internal UpdateConsumption.Request UpdateConsumptionRequest() { - CreateConsumption.Request createRequest = CreateConsumptionRequest(default); + CreateConsumption.Request createRequest = CreateConsumptionRequest(Guid.Empty); return new UpdateConsumption.Request( createRequest.DateTime, createRequest.Distance,