Skip to content

Commit

Permalink
feat: adjust tests to updated xunit
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilbaczek committed Nov 28, 2024
1 parent 77da9e7 commit c996604
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,20 @@ namespace EvolutionaryArchitecture.Fitnet.Contracts.Api.UnitTests.Prepare.Reques

using EvolutionaryArchitecture.Fitnet.Contracts.Api.Prepare;

internal sealed class InvalidPrepareContractRequestTestCases : TheoryData<PrepareContractRequest>
internal sealed class InvalidPrepareContractRequestTestCases : TheoryData<string, int, int, DateTimeOffset, string>
{
private readonly Faker _faker = new();
private readonly DateTimeOffset _fakeNow = new Faker().Date.RecentOffset();

public InvalidPrepareContractRequestTestCases()
{
var validContractParameters = PrepareContractRequestParameters.GetValid();
AddRow(
new PrepareContractRequest(Guid.Empty, validContractParameters.MinAge, validContractParameters.MaxHeight,
_fakeNow), nameof(PrepareContractRequest.CustomerId));
AddRow(new PrepareContractRequest(Guid.NewGuid(), default, validContractParameters.MaxHeight, _fakeNow),
nameof(PrepareContractRequest.CustomerAge));
AddRow(
new PrepareContractRequest(Guid.NewGuid(), _faker.Random.Number(-100, -1),
validContractParameters.MaxHeight, _fakeNow), nameof(PrepareContractRequest.CustomerAge));
AddRow(new PrepareContractRequest(Guid.NewGuid(), validContractParameters.MinAge, default, _fakeNow),
nameof(PrepareContractRequest.CustomerHeight));
AddRow(
new PrepareContractRequest(Guid.NewGuid(), validContractParameters.MinAge, _faker.Random.Number(-100, -1),
_fakeNow), nameof(PrepareContractRequest.CustomerHeight));
AddRow(
new PrepareContractRequest(Guid.NewGuid(), validContractParameters.MinAge,
validContractParameters.MaxHeight, default), nameof(PrepareContractRequest.PreparedAt));
AddRow(
new PrepareContractRequest(Guid.NewGuid(), validContractParameters.MinAge,
validContractParameters.MaxHeight, default), nameof(PrepareContractRequest.PreparedAt));
Add(Guid.Empty.ToString(), validContractParameters.MinAge, validContractParameters.MaxHeight, _fakeNow, nameof(PrepareContractRequest.CustomerId));
Add(Guid.NewGuid().ToString(), default, validContractParameters.MaxHeight, _fakeNow, nameof(PrepareContractRequest.CustomerAge));
Add(Guid.NewGuid().ToString(), _faker.Random.Number(-100, -1), validContractParameters.MaxHeight, _fakeNow, nameof(PrepareContractRequest.CustomerAge));
Add(Guid.NewGuid().ToString(), validContractParameters.MinAge, default, _fakeNow, nameof(PrepareContractRequest.CustomerHeight));
Add(Guid.NewGuid().ToString(), validContractParameters.MinAge, _faker.Random.Number(-100, -1), _fakeNow, nameof(PrepareContractRequest.CustomerHeight));
Add(Guid.NewGuid().ToString(), validContractParameters.MinAge, validContractParameters.MaxHeight, default, nameof(PrepareContractRequest.PreparedAt));
Add(Guid.NewGuid().ToString(), validContractParameters.MinAge, validContractParameters.MaxHeight, default, nameof(PrepareContractRequest.PreparedAt));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ internal void Given_prepare_contract_request_validation_When_request_is_valid_Th
result.ShouldNotHaveAnyValidationErrors();
}

[Theory]
[ClassData(typeof(InvalidPrepareContractRequestTestCases))]
internal void Given_prepare_contract_request_validation_When_property_is_valid_Then_result_should_have_error(PrepareContractRequest request, string expectedInvalidPropertyName)
[Theory, ClassData(typeof(InvalidPrepareContractRequestTestCases))]
internal void Given_prepare_contract_request_validation_When_property_is_valid_Then_result_should_have_error(string customerId, int customerAge, int customerHeight, DateTimeOffset preparedAt, string expectedInvalidPropertyName)
{
// Arrange
var request = new PrepareContractRequest(Guid.Parse(customerId), customerAge, customerHeight, preparedAt);

// Act
var result = _validator.TestValidate(request);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<Version>1.0.7</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BouncyCastle.Cryptography" Version="2.4.0" />
<PackageReference Include="EvolutionaryArchitecture.Fitnet.Common.Infrastructure" Version="3.1.1" />
<PackageReference Include="System.Text.Encodings.Web" Version="9.0.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<PackageReference Include="evolutionaryarchitecture.fitnet.common.api" Version="3.1.1" />
<PackageReference Include="evolutionaryarchitecture.fitnet.common.integrationteststoolbox" Version="3.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Text.Json" Version="9.0.0" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit c996604

Please sign in to comment.