diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/NegativeDecimalEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/NegativeDecimalEntityTests.cs new file mode 100644 index 0000000..b005e2c --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/NegativeDecimalEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class NegativeDecimalEntityTests(TestWebApplicationFactory factory) + : EntityTests, Negative?, decimal>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "negative-decimal-entities"; + protected override Negative Create(decimal raw) => Negative.Create(raw); + protected override decimal FirstValid => -5m; + protected override decimal UpdatedValid => -100m; + + public static TheoryData ValidInputs => new() { -5m, -42m, -10m, -1m, -1.5m, -0.01m }; + public static TheoryData InvalidInputs => new() { 0m, 1m, 100m, 1.5m }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/NegativeDoubleEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/NegativeDoubleEntityTests.cs new file mode 100644 index 0000000..7a5835e --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/NegativeDoubleEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class NegativeDoubleEntityTests(TestWebApplicationFactory factory) + : EntityTests, Negative?, double>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "negative-double-entities"; + protected override Negative Create(double raw) => Negative.Create(raw); + protected override double FirstValid => -5d; + protected override double UpdatedValid => -100d; + + public static TheoryData ValidInputs => new() { -5d, -42d, -10d, -1d, -1.5d, double.MinValue }; + public static TheoryData InvalidInputs => new() { 0d, 1d, 100d, 1.5d, double.MaxValue }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/NegativeFloatEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/NegativeFloatEntityTests.cs new file mode 100644 index 0000000..45cbdd8 --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/NegativeFloatEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class NegativeFloatEntityTests(TestWebApplicationFactory factory) + : EntityTests, Negative?, float>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "negative-float-entities"; + protected override Negative Create(float raw) => Negative.Create(raw); + protected override float FirstValid => -5f; + protected override float UpdatedValid => -100f; + + public static TheoryData ValidInputs => new() { -5f, -42f, -10f, -1f, -1.5f, float.MinValue }; + public static TheoryData InvalidInputs => new() { 0f, 1f, 100f, 1.5f, float.MaxValue }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/NegativeLongEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/NegativeLongEntityTests.cs new file mode 100644 index 0000000..06856c8 --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/NegativeLongEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class NegativeLongEntityTests(TestWebApplicationFactory factory) + : EntityTests, Negative?, long>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "negative-long-entities"; + protected override Negative Create(long raw) => Negative.Create(raw); + protected override long FirstValid => -5L; + protected override long UpdatedValid => -100L; + + public static TheoryData ValidInputs => new() { -5L, -42L, -10L, -1L, long.MinValue }; + public static TheoryData InvalidInputs => new() { 0L, 1L, 100L, long.MaxValue }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/NegativeShortEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/NegativeShortEntityTests.cs new file mode 100644 index 0000000..0a2d100 --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/NegativeShortEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class NegativeShortEntityTests(TestWebApplicationFactory factory) + : EntityTests, Negative?, short>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "negative-short-entities"; + protected override Negative Create(short raw) => Negative.Create(raw); + protected override short FirstValid => -5; + protected override short UpdatedValid => -100; + + public static TheoryData ValidInputs => new() { (short)-5, (short)-42, (short)-10, (short)-1, short.MinValue }; + public static TheoryData InvalidInputs => new() { (short)0, (short)1, (short)100, short.MaxValue }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/NonNegativeDecimalEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/NonNegativeDecimalEntityTests.cs new file mode 100644 index 0000000..2cc18a5 --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/NonNegativeDecimalEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class NonNegativeDecimalEntityTests(TestWebApplicationFactory factory) + : EntityTests, NonNegative?, decimal>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "non-negative-decimal-entities"; + protected override NonNegative Create(decimal raw) => NonNegative.Create(raw); + protected override decimal FirstValid => 0m; + protected override decimal UpdatedValid => 100m; + + public static TheoryData ValidInputs => new() { 0m, 5m, 42m, 10m, 1.5m, 0.01m }; + public static TheoryData InvalidInputs => new() { -1m, -100m, -1.5m }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/NonNegativeDoubleEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/NonNegativeDoubleEntityTests.cs new file mode 100644 index 0000000..ef2e7c2 --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/NonNegativeDoubleEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class NonNegativeDoubleEntityTests(TestWebApplicationFactory factory) + : EntityTests, NonNegative?, double>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "non-negative-double-entities"; + protected override NonNegative Create(double raw) => NonNegative.Create(raw); + protected override double FirstValid => 0d; + protected override double UpdatedValid => 100d; + + public static TheoryData ValidInputs => new() { 0d, 5d, 42d, 10d, 1.5d, double.MaxValue }; + public static TheoryData InvalidInputs => new() { -1d, -100d, -1.5d, double.MinValue }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/NonNegativeFloatEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/NonNegativeFloatEntityTests.cs new file mode 100644 index 0000000..6e2680b --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/NonNegativeFloatEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class NonNegativeFloatEntityTests(TestWebApplicationFactory factory) + : EntityTests, NonNegative?, float>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "non-negative-float-entities"; + protected override NonNegative Create(float raw) => NonNegative.Create(raw); + protected override float FirstValid => 0f; + protected override float UpdatedValid => 100f; + + public static TheoryData ValidInputs => new() { 0f, 5f, 42f, 10f, 1.5f, float.MaxValue }; + public static TheoryData InvalidInputs => new() { -1f, -100f, -1.5f, float.MinValue }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/NonNegativeLongEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/NonNegativeLongEntityTests.cs new file mode 100644 index 0000000..3a0e6c1 --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/NonNegativeLongEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class NonNegativeLongEntityTests(TestWebApplicationFactory factory) + : EntityTests, NonNegative?, long>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "non-negative-long-entities"; + protected override NonNegative Create(long raw) => NonNegative.Create(raw); + protected override long FirstValid => 0L; + protected override long UpdatedValid => 100L; + + public static TheoryData ValidInputs => new() { 0L, 5L, 42L, 10L, long.MaxValue }; + public static TheoryData InvalidInputs => new() { -1L, -100L, long.MinValue }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/NonNegativeShortEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/NonNegativeShortEntityTests.cs new file mode 100644 index 0000000..b5e7b39 --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/NonNegativeShortEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class NonNegativeShortEntityTests(TestWebApplicationFactory factory) + : EntityTests, NonNegative?, short>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "non-negative-short-entities"; + protected override NonNegative Create(short raw) => NonNegative.Create(raw); + protected override short FirstValid => 0; + protected override short UpdatedValid => 100; + + public static TheoryData ValidInputs => new() { (short)0, (short)5, (short)42, (short)10, short.MaxValue }; + public static TheoryData InvalidInputs => new() { (short)-1, (short)-100, short.MinValue }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/NonPositiveDecimalEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/NonPositiveDecimalEntityTests.cs new file mode 100644 index 0000000..493047f --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/NonPositiveDecimalEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class NonPositiveDecimalEntityTests(TestWebApplicationFactory factory) + : EntityTests, NonPositive?, decimal>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "non-positive-decimal-entities"; + protected override NonPositive Create(decimal raw) => NonPositive.Create(raw); + protected override decimal FirstValid => 0m; + protected override decimal UpdatedValid => -100m; + + public static TheoryData ValidInputs => new() { 0m, -5m, -42m, -10m, -1.5m, -0.01m }; + public static TheoryData InvalidInputs => new() { 1m, 100m, 1.5m }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/NonPositiveDoubleEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/NonPositiveDoubleEntityTests.cs new file mode 100644 index 0000000..602652b --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/NonPositiveDoubleEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class NonPositiveDoubleEntityTests(TestWebApplicationFactory factory) + : EntityTests, NonPositive?, double>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "non-positive-double-entities"; + protected override NonPositive Create(double raw) => NonPositive.Create(raw); + protected override double FirstValid => 0d; + protected override double UpdatedValid => -100d; + + public static TheoryData ValidInputs => new() { 0d, -5d, -42d, -10d, -1.5d, double.MinValue }; + public static TheoryData InvalidInputs => new() { 1d, 100d, 1.5d, double.MaxValue }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/NonPositiveFloatEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/NonPositiveFloatEntityTests.cs new file mode 100644 index 0000000..d361c57 --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/NonPositiveFloatEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class NonPositiveFloatEntityTests(TestWebApplicationFactory factory) + : EntityTests, NonPositive?, float>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "non-positive-float-entities"; + protected override NonPositive Create(float raw) => NonPositive.Create(raw); + protected override float FirstValid => 0f; + protected override float UpdatedValid => -100f; + + public static TheoryData ValidInputs => new() { 0f, -5f, -42f, -10f, -1.5f, float.MinValue }; + public static TheoryData InvalidInputs => new() { 1f, 100f, 1.5f, float.MaxValue }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/NonPositiveLongEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/NonPositiveLongEntityTests.cs new file mode 100644 index 0000000..901843c --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/NonPositiveLongEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class NonPositiveLongEntityTests(TestWebApplicationFactory factory) + : EntityTests, NonPositive?, long>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "non-positive-long-entities"; + protected override NonPositive Create(long raw) => NonPositive.Create(raw); + protected override long FirstValid => 0L; + protected override long UpdatedValid => -100L; + + public static TheoryData ValidInputs => new() { 0L, -5L, -42L, -10L, long.MinValue }; + public static TheoryData InvalidInputs => new() { 1L, 100L, long.MaxValue }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/NonPositiveShortEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/NonPositiveShortEntityTests.cs new file mode 100644 index 0000000..b113d14 --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/NonPositiveShortEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class NonPositiveShortEntityTests(TestWebApplicationFactory factory) + : EntityTests, NonPositive?, short>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "non-positive-short-entities"; + protected override NonPositive Create(short raw) => NonPositive.Create(raw); + protected override short FirstValid => 0; + protected override short UpdatedValid => -100; + + public static TheoryData ValidInputs => new() { (short)0, (short)-5, (short)-42, (short)-10, short.MinValue }; + public static TheoryData InvalidInputs => new() { (short)1, (short)100, short.MaxValue }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/PositiveDecimalEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/PositiveDecimalEntityTests.cs new file mode 100644 index 0000000..a0f9c2a --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/PositiveDecimalEntityTests.cs @@ -0,0 +1,21 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +// Values are constrained to two decimal places so they round-trip exactly +// through EF Core's default SQL Server decimal(18,2) mapping. +[Collection(IntegrationTestCollection.Name)] +public sealed class PositiveDecimalEntityTests(TestWebApplicationFactory factory) + : EntityTests, Positive?, decimal>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "positive-decimal-entities"; + protected override Positive Create(decimal raw) => Positive.Create(raw); + protected override decimal FirstValid => 5m; + protected override decimal UpdatedValid => 100m; + + public static TheoryData ValidInputs => new() { 5m, 42m, 10m, 1m, 1.5m, 0.01m }; + public static TheoryData InvalidInputs => new() { 0m, -1m, -100m, -1.5m }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/PositiveDoubleEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/PositiveDoubleEntityTests.cs new file mode 100644 index 0000000..7024ade --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/PositiveDoubleEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class PositiveDoubleEntityTests(TestWebApplicationFactory factory) + : EntityTests, Positive?, double>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "positive-double-entities"; + protected override Positive Create(double raw) => Positive.Create(raw); + protected override double FirstValid => 5d; + protected override double UpdatedValid => 100d; + + public static TheoryData ValidInputs => new() { 5d, 42d, 10d, 1d, 1.5d, double.MaxValue }; + public static TheoryData InvalidInputs => new() { 0d, -1d, -100d, -1.5d, double.MinValue }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/PositiveFloatEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/PositiveFloatEntityTests.cs new file mode 100644 index 0000000..1fc692f --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/PositiveFloatEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class PositiveFloatEntityTests(TestWebApplicationFactory factory) + : EntityTests, Positive?, float>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "positive-float-entities"; + protected override Positive Create(float raw) => Positive.Create(raw); + protected override float FirstValid => 5f; + protected override float UpdatedValid => 100f; + + public static TheoryData ValidInputs => new() { 5f, 42f, 10f, 1f, 1.5f, float.MaxValue }; + public static TheoryData InvalidInputs => new() { 0f, -1f, -100f, -1.5f, float.MinValue }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/PositiveLongEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/PositiveLongEntityTests.cs new file mode 100644 index 0000000..49504ec --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/PositiveLongEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class PositiveLongEntityTests(TestWebApplicationFactory factory) + : EntityTests, Positive?, long>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "positive-long-entities"; + protected override Positive Create(long raw) => Positive.Create(raw); + protected override long FirstValid => 5L; + protected override long UpdatedValid => 100L; + + public static TheoryData ValidInputs => new() { 5L, 42L, 10L, 1L, long.MaxValue }; + public static TheoryData InvalidInputs => new() { 0L, -1L, -100L, long.MinValue }; +} diff --git a/src/StrongTypes.Api.IntegrationTests/Tests/PositiveShortEntityTests.cs b/src/StrongTypes.Api.IntegrationTests/Tests/PositiveShortEntityTests.cs new file mode 100644 index 0000000..f86f87a --- /dev/null +++ b/src/StrongTypes.Api.IntegrationTests/Tests/PositiveShortEntityTests.cs @@ -0,0 +1,19 @@ +using StrongTypes.Api.Entities; +using StrongTypes.Api.IntegrationTests.Infrastructure; +using Xunit; + +namespace StrongTypes.Api.IntegrationTests.Tests; + +[Collection(IntegrationTestCollection.Name)] +public sealed class PositiveShortEntityTests(TestWebApplicationFactory factory) + : EntityTests, Positive?, short>(factory), + IEntityTestData +{ + protected override string RoutePrefix => "positive-short-entities"; + protected override Positive Create(short raw) => Positive.Create(raw); + protected override short FirstValid => 5; + protected override short UpdatedValid => 100; + + public static TheoryData ValidInputs => new() { (short)5, (short)42, (short)10, (short)1, short.MaxValue }; + public static TheoryData InvalidInputs => new() { (short)0, (short)-1, (short)-100, short.MinValue }; +} diff --git a/src/StrongTypes.Api/Controllers/NegativeDecimalEntityController.cs b/src/StrongTypes.Api/Controllers/NegativeDecimalEntityController.cs new file mode 100644 index 0000000..7356f59 --- /dev/null +++ b/src/StrongTypes.Api/Controllers/NegativeDecimalEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("negative-decimal-entities")] +public sealed class NegativeDecimalEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, Negative?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/NegativeDoubleEntityController.cs b/src/StrongTypes.Api/Controllers/NegativeDoubleEntityController.cs new file mode 100644 index 0000000..9a2ae9b --- /dev/null +++ b/src/StrongTypes.Api/Controllers/NegativeDoubleEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("negative-double-entities")] +public sealed class NegativeDoubleEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, Negative?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/NegativeFloatEntityController.cs b/src/StrongTypes.Api/Controllers/NegativeFloatEntityController.cs new file mode 100644 index 0000000..e900ee0 --- /dev/null +++ b/src/StrongTypes.Api/Controllers/NegativeFloatEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("negative-float-entities")] +public sealed class NegativeFloatEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, Negative?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/NegativeLongEntityController.cs b/src/StrongTypes.Api/Controllers/NegativeLongEntityController.cs new file mode 100644 index 0000000..32e67a2 --- /dev/null +++ b/src/StrongTypes.Api/Controllers/NegativeLongEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("negative-long-entities")] +public sealed class NegativeLongEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, Negative?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/NegativeShortEntityController.cs b/src/StrongTypes.Api/Controllers/NegativeShortEntityController.cs new file mode 100644 index 0000000..98c4f97 --- /dev/null +++ b/src/StrongTypes.Api/Controllers/NegativeShortEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("negative-short-entities")] +public sealed class NegativeShortEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, Negative?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/NonNegativeDecimalEntityController.cs b/src/StrongTypes.Api/Controllers/NonNegativeDecimalEntityController.cs new file mode 100644 index 0000000..d5faab9 --- /dev/null +++ b/src/StrongTypes.Api/Controllers/NonNegativeDecimalEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("non-negative-decimal-entities")] +public sealed class NonNegativeDecimalEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, NonNegative?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/NonNegativeDoubleEntityController.cs b/src/StrongTypes.Api/Controllers/NonNegativeDoubleEntityController.cs new file mode 100644 index 0000000..c97929a --- /dev/null +++ b/src/StrongTypes.Api/Controllers/NonNegativeDoubleEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("non-negative-double-entities")] +public sealed class NonNegativeDoubleEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, NonNegative?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/NonNegativeFloatEntityController.cs b/src/StrongTypes.Api/Controllers/NonNegativeFloatEntityController.cs new file mode 100644 index 0000000..4d36f08 --- /dev/null +++ b/src/StrongTypes.Api/Controllers/NonNegativeFloatEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("non-negative-float-entities")] +public sealed class NonNegativeFloatEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, NonNegative?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/NonNegativeLongEntityController.cs b/src/StrongTypes.Api/Controllers/NonNegativeLongEntityController.cs new file mode 100644 index 0000000..eff2ea0 --- /dev/null +++ b/src/StrongTypes.Api/Controllers/NonNegativeLongEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("non-negative-long-entities")] +public sealed class NonNegativeLongEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, NonNegative?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/NonNegativeShortEntityController.cs b/src/StrongTypes.Api/Controllers/NonNegativeShortEntityController.cs new file mode 100644 index 0000000..d47d647 --- /dev/null +++ b/src/StrongTypes.Api/Controllers/NonNegativeShortEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("non-negative-short-entities")] +public sealed class NonNegativeShortEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, NonNegative?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/NonPositiveDecimalEntityController.cs b/src/StrongTypes.Api/Controllers/NonPositiveDecimalEntityController.cs new file mode 100644 index 0000000..5da97ca --- /dev/null +++ b/src/StrongTypes.Api/Controllers/NonPositiveDecimalEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("non-positive-decimal-entities")] +public sealed class NonPositiveDecimalEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, NonPositive?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/NonPositiveDoubleEntityController.cs b/src/StrongTypes.Api/Controllers/NonPositiveDoubleEntityController.cs new file mode 100644 index 0000000..7bdb588 --- /dev/null +++ b/src/StrongTypes.Api/Controllers/NonPositiveDoubleEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("non-positive-double-entities")] +public sealed class NonPositiveDoubleEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, NonPositive?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/NonPositiveFloatEntityController.cs b/src/StrongTypes.Api/Controllers/NonPositiveFloatEntityController.cs new file mode 100644 index 0000000..41f60b0 --- /dev/null +++ b/src/StrongTypes.Api/Controllers/NonPositiveFloatEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("non-positive-float-entities")] +public sealed class NonPositiveFloatEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, NonPositive?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/NonPositiveLongEntityController.cs b/src/StrongTypes.Api/Controllers/NonPositiveLongEntityController.cs new file mode 100644 index 0000000..e9744c7 --- /dev/null +++ b/src/StrongTypes.Api/Controllers/NonPositiveLongEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("non-positive-long-entities")] +public sealed class NonPositiveLongEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, NonPositive?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/NonPositiveShortEntityController.cs b/src/StrongTypes.Api/Controllers/NonPositiveShortEntityController.cs new file mode 100644 index 0000000..85c559e --- /dev/null +++ b/src/StrongTypes.Api/Controllers/NonPositiveShortEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("non-positive-short-entities")] +public sealed class NonPositiveShortEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, NonPositive?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/PositiveDecimalEntityController.cs b/src/StrongTypes.Api/Controllers/PositiveDecimalEntityController.cs new file mode 100644 index 0000000..1cf5625 --- /dev/null +++ b/src/StrongTypes.Api/Controllers/PositiveDecimalEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("positive-decimal-entities")] +public sealed class PositiveDecimalEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, Positive?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/PositiveDoubleEntityController.cs b/src/StrongTypes.Api/Controllers/PositiveDoubleEntityController.cs new file mode 100644 index 0000000..6c851a7 --- /dev/null +++ b/src/StrongTypes.Api/Controllers/PositiveDoubleEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("positive-double-entities")] +public sealed class PositiveDoubleEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, Positive?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/PositiveFloatEntityController.cs b/src/StrongTypes.Api/Controllers/PositiveFloatEntityController.cs new file mode 100644 index 0000000..bf3a29a --- /dev/null +++ b/src/StrongTypes.Api/Controllers/PositiveFloatEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("positive-float-entities")] +public sealed class PositiveFloatEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, Positive?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/PositiveLongEntityController.cs b/src/StrongTypes.Api/Controllers/PositiveLongEntityController.cs new file mode 100644 index 0000000..1cf6b57 --- /dev/null +++ b/src/StrongTypes.Api/Controllers/PositiveLongEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("positive-long-entities")] +public sealed class PositiveLongEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, Positive?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Controllers/PositiveShortEntityController.cs b/src/StrongTypes.Api/Controllers/PositiveShortEntityController.cs new file mode 100644 index 0000000..9ecdd66 --- /dev/null +++ b/src/StrongTypes.Api/Controllers/PositiveShortEntityController.cs @@ -0,0 +1,10 @@ +using Microsoft.AspNetCore.Mvc; +using StrongTypes.Api.Data; +using StrongTypes.Api.Entities; + +namespace StrongTypes.Api.Controllers; + +[ApiController] +[Route("positive-short-entities")] +public sealed class PositiveShortEntityController(SqlServerDbContext sqlCtx, PostgreSqlDbContext pgCtx) + : EntityControllerBase, Positive?>(sqlCtx, pgCtx); diff --git a/src/StrongTypes.Api/Data/PostgreSqlDbContext.cs b/src/StrongTypes.Api/Data/PostgreSqlDbContext.cs index 079bb93..f28c95e 100644 --- a/src/StrongTypes.Api/Data/PostgreSqlDbContext.cs +++ b/src/StrongTypes.Api/Data/PostgreSqlDbContext.cs @@ -7,11 +7,37 @@ namespace StrongTypes.Api.Data; public class PostgreSqlDbContext(DbContextOptions options) : DbContext(options) { public DbSet NonEmptyStringEntities { get; set; } + public DbSet PositiveIntEntities { get; set; } public DbSet NonNegativeIntEntities { get; set; } public DbSet NegativeIntEntities { get; set; } public DbSet NonPositiveIntEntities { get; set; } + public DbSet PositiveLongEntities { get; set; } + public DbSet NonNegativeLongEntities { get; set; } + public DbSet NegativeLongEntities { get; set; } + public DbSet NonPositiveLongEntities { get; set; } + + public DbSet PositiveShortEntities { get; set; } + public DbSet NonNegativeShortEntities { get; set; } + public DbSet NegativeShortEntities { get; set; } + public DbSet NonPositiveShortEntities { get; set; } + + public DbSet PositiveDecimalEntities { get; set; } + public DbSet NonNegativeDecimalEntities { get; set; } + public DbSet NegativeDecimalEntities { get; set; } + public DbSet NonPositiveDecimalEntities { get; set; } + + public DbSet PositiveFloatEntities { get; set; } + public DbSet NonNegativeFloatEntities { get; set; } + public DbSet NegativeFloatEntities { get; set; } + public DbSet NonPositiveFloatEntities { get; set; } + + public DbSet PositiveDoubleEntities { get; set; } + public DbSet NonNegativeDoubleEntities { get; set; } + public DbSet NegativeDoubleEntities { get; set; } + public DbSet NonPositiveDoubleEntities { get; set; } + protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) => configurationBuilder.UseStrongTypes(); } diff --git a/src/StrongTypes.Api/Data/SqlServerDbContext.cs b/src/StrongTypes.Api/Data/SqlServerDbContext.cs index 2f8aa56..3004ddd 100644 --- a/src/StrongTypes.Api/Data/SqlServerDbContext.cs +++ b/src/StrongTypes.Api/Data/SqlServerDbContext.cs @@ -7,11 +7,37 @@ namespace StrongTypes.Api.Data; public class SqlServerDbContext(DbContextOptions options) : DbContext(options) { public DbSet NonEmptyStringEntities { get; set; } + public DbSet PositiveIntEntities { get; set; } public DbSet NonNegativeIntEntities { get; set; } public DbSet NegativeIntEntities { get; set; } public DbSet NonPositiveIntEntities { get; set; } + public DbSet PositiveLongEntities { get; set; } + public DbSet NonNegativeLongEntities { get; set; } + public DbSet NegativeLongEntities { get; set; } + public DbSet NonPositiveLongEntities { get; set; } + + public DbSet PositiveShortEntities { get; set; } + public DbSet NonNegativeShortEntities { get; set; } + public DbSet NegativeShortEntities { get; set; } + public DbSet NonPositiveShortEntities { get; set; } + + public DbSet PositiveDecimalEntities { get; set; } + public DbSet NonNegativeDecimalEntities { get; set; } + public DbSet NegativeDecimalEntities { get; set; } + public DbSet NonPositiveDecimalEntities { get; set; } + + public DbSet PositiveFloatEntities { get; set; } + public DbSet NonNegativeFloatEntities { get; set; } + public DbSet NegativeFloatEntities { get; set; } + public DbSet NonPositiveFloatEntities { get; set; } + + public DbSet PositiveDoubleEntities { get; set; } + public DbSet NonNegativeDoubleEntities { get; set; } + public DbSet NegativeDoubleEntities { get; set; } + public DbSet NonPositiveDoubleEntities { get; set; } + protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) => configurationBuilder.UseStrongTypes(); } diff --git a/src/StrongTypes.Api/Entities/Entities.cs b/src/StrongTypes.Api/Entities/Entities.cs index e2b4789..06ccf0b 100644 --- a/src/StrongTypes.Api/Entities/Entities.cs +++ b/src/StrongTypes.Api/Entities/Entities.cs @@ -3,9 +3,31 @@ namespace StrongTypes.Api.Entities; public sealed class NonEmptyStringEntity : EntityBase; public sealed class PositiveIntEntity : EntityBase, Positive?>; - public sealed class NonNegativeIntEntity : EntityBase, NonNegative?>; - public sealed class NegativeIntEntity : EntityBase, Negative?>; - public sealed class NonPositiveIntEntity : EntityBase, NonPositive?>; + +public sealed class PositiveLongEntity : EntityBase, Positive?>; +public sealed class NonNegativeLongEntity : EntityBase, NonNegative?>; +public sealed class NegativeLongEntity : EntityBase, Negative?>; +public sealed class NonPositiveLongEntity : EntityBase, NonPositive?>; + +public sealed class PositiveShortEntity : EntityBase, Positive?>; +public sealed class NonNegativeShortEntity : EntityBase, NonNegative?>; +public sealed class NegativeShortEntity : EntityBase, Negative?>; +public sealed class NonPositiveShortEntity : EntityBase, NonPositive?>; + +public sealed class PositiveDecimalEntity : EntityBase, Positive?>; +public sealed class NonNegativeDecimalEntity : EntityBase, NonNegative?>; +public sealed class NegativeDecimalEntity : EntityBase, Negative?>; +public sealed class NonPositiveDecimalEntity : EntityBase, NonPositive?>; + +public sealed class PositiveFloatEntity : EntityBase, Positive?>; +public sealed class NonNegativeFloatEntity : EntityBase, NonNegative?>; +public sealed class NegativeFloatEntity : EntityBase, Negative?>; +public sealed class NonPositiveFloatEntity : EntityBase, NonPositive?>; + +public sealed class PositiveDoubleEntity : EntityBase, Positive?>; +public sealed class NonNegativeDoubleEntity : EntityBase, NonNegative?>; +public sealed class NegativeDoubleEntity : EntityBase, Negative?>; +public sealed class NonPositiveDoubleEntity : EntityBase, NonPositive?>;