Kalicz.StrongTypes.FsCheck
1.1.0
dotnet add package Kalicz.StrongTypes.FsCheck --version 1.1.0
NuGet\Install-Package Kalicz.StrongTypes.FsCheck -Version 1.1.0
<PackageReference Include="Kalicz.StrongTypes.FsCheck" Version="1.1.0" />
<PackageVersion Include="Kalicz.StrongTypes.FsCheck" Version="1.1.0" />
<PackageReference Include="Kalicz.StrongTypes.FsCheck" />
paket add Kalicz.StrongTypes.FsCheck --version 1.1.0
#r "nuget: Kalicz.StrongTypes.FsCheck, 1.1.0"
#:package Kalicz.StrongTypes.FsCheck@1.1.0
#addin nuget:?package=Kalicz.StrongTypes.FsCheck&version=1.1.0
#tool nuget:?package=Kalicz.StrongTypes.FsCheck&version=1.1.0
Kalicz.StrongTypes.FsCheck
FsCheck arbitraries for Kalicz.StrongTypes.
Lets you write property tests against code that takes or returns NonEmptyString,
Digit, Positive<T>, NonNegative<T>, Negative<T>, NonPositive<T>, Maybe<T>,
and NonEmptyEnumerable<T> without hand-rolling generators that re-derive each
type's invariants.
Install
dotnet add package Kalicz.StrongTypes.FsCheck
Register
Register everything with one attribute on your test class:
using FsCheck.Xunit;
using StrongTypes.FsCheck;
[Properties(Arbitrary = new[] { typeof(Generators) })]
public class MyTests
{
[Property]
public void NonEmptyString_round_trips_through_json(NonEmptyString value)
{
// value is guaranteed non-null, non-empty, non-whitespace
}
[Property]
public void Positive_stays_positive(Positive<int> value)
{
Assert.True(value.Value > 0);
}
}
What ships
Scalar strong types ship three shapes: the type itself, its nullable form
(T?, ~5% null), and Maybe<T> (~5% None).
| Type | T |
T? |
Maybe<T> |
|---|---|---|---|
NonEmptyString |
NonEmptyString |
NullableNonEmptyString |
MaybeNonEmptyString |
Digit |
Digit |
NullableDigit |
MaybeDigit |
Positive<int> |
PositiveInt |
NullablePositiveInt |
MaybePositiveInt |
Negative<int> |
NegativeInt |
NullableNegativeInt |
MaybeNegativeInt |
NonNegative<int> |
NonNegativeInt |
NullableNonNegativeInt |
MaybeNonNegativeInt |
NonPositive<int> |
NonPositiveInt |
NullableNonPositiveInt |
MaybeNonPositiveInt |
Apart from the above, you also get:
NonEmptyEnumerableInt—NonEmptyEnumerable<int>Maybe<T>for common primitives:MaybeBool,MaybeInt,MaybeLong,MaybeDouble,MaybeChar,MaybeString,MaybeGuid— all with ~5%None.
Version matches the core Kalicz.StrongTypes package you install alongside it.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- FsCheck (>= 3.0.0 && < 4.0.0)
- Kalicz.StrongTypes (>= 1.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.