Skip to content

Commit 11dcb0b

Browse files
KaliCZclaude
andcommitted
Extend numeric integration tests to long, short, decimal, float, double (#26)
Adds entity/controller/test classes for every (constraint × underlying type) combo beyond int, so the end-to-end ASP.NET Core + EF Core pipeline is exercised for Positive/NonNegative/Negative/NonPositive across all supported numeric underlying types. Test suite grows from 101 to 501 tests, all passing against both SQL Server and PostgreSQL. Decimal test values stay within two fractional digits so they round-trip through EF Core's default SQL Server decimal(18,2) mapping. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d678b6b commit 11dcb0b

43 files changed

Lines changed: 659 additions & 3 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using StrongTypes.Api.Entities;
2+
using StrongTypes.Api.IntegrationTests.Infrastructure;
3+
using Xunit;
4+
5+
namespace StrongTypes.Api.IntegrationTests.Tests;
6+
7+
[Collection(IntegrationTestCollection.Name)]
8+
public sealed class NegativeDecimalEntityTests(TestWebApplicationFactory factory)
9+
: EntityTests<NegativeDecimalEntityTests, NegativeDecimalEntity, Negative<decimal>, Negative<decimal>?, decimal>(factory),
10+
IEntityTestData<decimal>
11+
{
12+
protected override string RoutePrefix => "negative-decimal-entities";
13+
protected override Negative<decimal> Create(decimal raw) => Negative<decimal>.Create(raw);
14+
protected override decimal FirstValid => -5m;
15+
protected override decimal UpdatedValid => -100m;
16+
17+
public static TheoryData<decimal> ValidInputs => new() { -5m, -42m, -10m, -1m, -1.5m, -0.01m };
18+
public static TheoryData<decimal> InvalidInputs => new() { 0m, 1m, 100m, 1.5m };
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using StrongTypes.Api.Entities;
2+
using StrongTypes.Api.IntegrationTests.Infrastructure;
3+
using Xunit;
4+
5+
namespace StrongTypes.Api.IntegrationTests.Tests;
6+
7+
[Collection(IntegrationTestCollection.Name)]
8+
public sealed class NegativeDoubleEntityTests(TestWebApplicationFactory factory)
9+
: EntityTests<NegativeDoubleEntityTests, NegativeDoubleEntity, Negative<double>, Negative<double>?, double>(factory),
10+
IEntityTestData<double>
11+
{
12+
protected override string RoutePrefix => "negative-double-entities";
13+
protected override Negative<double> Create(double raw) => Negative<double>.Create(raw);
14+
protected override double FirstValid => -5d;
15+
protected override double UpdatedValid => -100d;
16+
17+
public static TheoryData<double> ValidInputs => new() { -5d, -42d, -10d, -1d, -1.5d, double.MinValue };
18+
public static TheoryData<double> InvalidInputs => new() { 0d, 1d, 100d, 1.5d, double.MaxValue };
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using StrongTypes.Api.Entities;
2+
using StrongTypes.Api.IntegrationTests.Infrastructure;
3+
using Xunit;
4+
5+
namespace StrongTypes.Api.IntegrationTests.Tests;
6+
7+
[Collection(IntegrationTestCollection.Name)]
8+
public sealed class NegativeFloatEntityTests(TestWebApplicationFactory factory)
9+
: EntityTests<NegativeFloatEntityTests, NegativeFloatEntity, Negative<float>, Negative<float>?, float>(factory),
10+
IEntityTestData<float>
11+
{
12+
protected override string RoutePrefix => "negative-float-entities";
13+
protected override Negative<float> Create(float raw) => Negative<float>.Create(raw);
14+
protected override float FirstValid => -5f;
15+
protected override float UpdatedValid => -100f;
16+
17+
public static TheoryData<float> ValidInputs => new() { -5f, -42f, -10f, -1f, -1.5f, float.MinValue };
18+
public static TheoryData<float> InvalidInputs => new() { 0f, 1f, 100f, 1.5f, float.MaxValue };
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using StrongTypes.Api.Entities;
2+
using StrongTypes.Api.IntegrationTests.Infrastructure;
3+
using Xunit;
4+
5+
namespace StrongTypes.Api.IntegrationTests.Tests;
6+
7+
[Collection(IntegrationTestCollection.Name)]
8+
public sealed class NegativeLongEntityTests(TestWebApplicationFactory factory)
9+
: EntityTests<NegativeLongEntityTests, NegativeLongEntity, Negative<long>, Negative<long>?, long>(factory),
10+
IEntityTestData<long>
11+
{
12+
protected override string RoutePrefix => "negative-long-entities";
13+
protected override Negative<long> Create(long raw) => Negative<long>.Create(raw);
14+
protected override long FirstValid => -5L;
15+
protected override long UpdatedValid => -100L;
16+
17+
public static TheoryData<long> ValidInputs => new() { -5L, -42L, -10L, -1L, long.MinValue };
18+
public static TheoryData<long> InvalidInputs => new() { 0L, 1L, 100L, long.MaxValue };
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using StrongTypes.Api.Entities;
2+
using StrongTypes.Api.IntegrationTests.Infrastructure;
3+
using Xunit;
4+
5+
namespace StrongTypes.Api.IntegrationTests.Tests;
6+
7+
[Collection(IntegrationTestCollection.Name)]
8+
public sealed class NegativeShortEntityTests(TestWebApplicationFactory factory)
9+
: EntityTests<NegativeShortEntityTests, NegativeShortEntity, Negative<short>, Negative<short>?, short>(factory),
10+
IEntityTestData<short>
11+
{
12+
protected override string RoutePrefix => "negative-short-entities";
13+
protected override Negative<short> Create(short raw) => Negative<short>.Create(raw);
14+
protected override short FirstValid => -5;
15+
protected override short UpdatedValid => -100;
16+
17+
public static TheoryData<short> ValidInputs => new() { (short)-5, (short)-42, (short)-10, (short)-1, short.MinValue };
18+
public static TheoryData<short> InvalidInputs => new() { (short)0, (short)1, (short)100, short.MaxValue };
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using StrongTypes.Api.Entities;
2+
using StrongTypes.Api.IntegrationTests.Infrastructure;
3+
using Xunit;
4+
5+
namespace StrongTypes.Api.IntegrationTests.Tests;
6+
7+
[Collection(IntegrationTestCollection.Name)]
8+
public sealed class NonNegativeDecimalEntityTests(TestWebApplicationFactory factory)
9+
: EntityTests<NonNegativeDecimalEntityTests, NonNegativeDecimalEntity, NonNegative<decimal>, NonNegative<decimal>?, decimal>(factory),
10+
IEntityTestData<decimal>
11+
{
12+
protected override string RoutePrefix => "non-negative-decimal-entities";
13+
protected override NonNegative<decimal> Create(decimal raw) => NonNegative<decimal>.Create(raw);
14+
protected override decimal FirstValid => 0m;
15+
protected override decimal UpdatedValid => 100m;
16+
17+
public static TheoryData<decimal> ValidInputs => new() { 0m, 5m, 42m, 10m, 1.5m, 0.01m };
18+
public static TheoryData<decimal> InvalidInputs => new() { -1m, -100m, -1.5m };
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using StrongTypes.Api.Entities;
2+
using StrongTypes.Api.IntegrationTests.Infrastructure;
3+
using Xunit;
4+
5+
namespace StrongTypes.Api.IntegrationTests.Tests;
6+
7+
[Collection(IntegrationTestCollection.Name)]
8+
public sealed class NonNegativeDoubleEntityTests(TestWebApplicationFactory factory)
9+
: EntityTests<NonNegativeDoubleEntityTests, NonNegativeDoubleEntity, NonNegative<double>, NonNegative<double>?, double>(factory),
10+
IEntityTestData<double>
11+
{
12+
protected override string RoutePrefix => "non-negative-double-entities";
13+
protected override NonNegative<double> Create(double raw) => NonNegative<double>.Create(raw);
14+
protected override double FirstValid => 0d;
15+
protected override double UpdatedValid => 100d;
16+
17+
public static TheoryData<double> ValidInputs => new() { 0d, 5d, 42d, 10d, 1.5d, double.MaxValue };
18+
public static TheoryData<double> InvalidInputs => new() { -1d, -100d, -1.5d, double.MinValue };
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using StrongTypes.Api.Entities;
2+
using StrongTypes.Api.IntegrationTests.Infrastructure;
3+
using Xunit;
4+
5+
namespace StrongTypes.Api.IntegrationTests.Tests;
6+
7+
[Collection(IntegrationTestCollection.Name)]
8+
public sealed class NonNegativeFloatEntityTests(TestWebApplicationFactory factory)
9+
: EntityTests<NonNegativeFloatEntityTests, NonNegativeFloatEntity, NonNegative<float>, NonNegative<float>?, float>(factory),
10+
IEntityTestData<float>
11+
{
12+
protected override string RoutePrefix => "non-negative-float-entities";
13+
protected override NonNegative<float> Create(float raw) => NonNegative<float>.Create(raw);
14+
protected override float FirstValid => 0f;
15+
protected override float UpdatedValid => 100f;
16+
17+
public static TheoryData<float> ValidInputs => new() { 0f, 5f, 42f, 10f, 1.5f, float.MaxValue };
18+
public static TheoryData<float> InvalidInputs => new() { -1f, -100f, -1.5f, float.MinValue };
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using StrongTypes.Api.Entities;
2+
using StrongTypes.Api.IntegrationTests.Infrastructure;
3+
using Xunit;
4+
5+
namespace StrongTypes.Api.IntegrationTests.Tests;
6+
7+
[Collection(IntegrationTestCollection.Name)]
8+
public sealed class NonNegativeLongEntityTests(TestWebApplicationFactory factory)
9+
: EntityTests<NonNegativeLongEntityTests, NonNegativeLongEntity, NonNegative<long>, NonNegative<long>?, long>(factory),
10+
IEntityTestData<long>
11+
{
12+
protected override string RoutePrefix => "non-negative-long-entities";
13+
protected override NonNegative<long> Create(long raw) => NonNegative<long>.Create(raw);
14+
protected override long FirstValid => 0L;
15+
protected override long UpdatedValid => 100L;
16+
17+
public static TheoryData<long> ValidInputs => new() { 0L, 5L, 42L, 10L, long.MaxValue };
18+
public static TheoryData<long> InvalidInputs => new() { -1L, -100L, long.MinValue };
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using StrongTypes.Api.Entities;
2+
using StrongTypes.Api.IntegrationTests.Infrastructure;
3+
using Xunit;
4+
5+
namespace StrongTypes.Api.IntegrationTests.Tests;
6+
7+
[Collection(IntegrationTestCollection.Name)]
8+
public sealed class NonNegativeShortEntityTests(TestWebApplicationFactory factory)
9+
: EntityTests<NonNegativeShortEntityTests, NonNegativeShortEntity, NonNegative<short>, NonNegative<short>?, short>(factory),
10+
IEntityTestData<short>
11+
{
12+
protected override string RoutePrefix => "non-negative-short-entities";
13+
protected override NonNegative<short> Create(short raw) => NonNegative<short>.Create(raw);
14+
protected override short FirstValid => 0;
15+
protected override short UpdatedValid => 100;
16+
17+
public static TheoryData<short> ValidInputs => new() { (short)0, (short)5, (short)42, (short)10, short.MaxValue };
18+
public static TheoryData<short> InvalidInputs => new() { (short)-1, (short)-100, short.MinValue };
19+
}

0 commit comments

Comments
 (0)