LiteSpecs 0.1.0
The owner has unlisted this package.
This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package LiteSpecs --version 0.1.0
NuGet\Install-Package LiteSpecs -Version 0.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LiteSpecs" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add LiteSpecs --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LiteSpecs, 0.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install LiteSpecs as a Cake Addin
#addin nuget:?package=LiteSpecs&version=0.1.0
// Install LiteSpecs as a Cake Tool
#tool nuget:?package=LiteSpecs&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Sample
Define some specifications. Either generic or typed:
static class TestSpecs
{
static readonly ISpecification<int> AllNumbers = Specification<int>.All;
static readonly ISpecification<int> OddNumbers = Specification.Generic<int>(
i => i % 2 != 0,
"Not an odd integer.");
static readonly ISpecification<int> Ones = Specification.Generic<int>(
i => i == 1,
"Not a 1.");
static readonly ISpecification<int> Threes = Specification.Generic<int>(
i => i == 3,
"Not a 3.");
static readonly ISpecification<VehicleObservation> CanBeObservationOfMotorcycle
= new CanBeObservationOfMotorcycle();
static readonly ISpecification<VehicleObservation> CanBeObservationOfCar
= new CanBeObservationOfCar();
static readonly ISpecification<VehicleObservation> CanBeObservationOfCar2
= Specification.Generic<VehicleObservation>(i =>
{
if (!i.HasEngine)
return SpecificationIs.NotSatisfied("A car must have an engine.");
if (i.WheelCount != 4)
return SpecificationIs.NotSatisfied("A car must have 4 wheels.");
return SpecificationIs.Satisfied;
});
}
public class CanBeObservationOfCar : Specification<VehicleObservation>
{
public CanBeObservationOfCar() : base(o =>
{
if (!o.HasEngine)
return SpecificationIs.NotSatisfied("A car must have an engine.");
if (o.WheelCount != 4)
return SpecificationIs.NotSatisfied("A car must have 4 wheels.");
return SpecificationIs.Satisfied;
})
{ }
}
public class CanBeObservationOfMotorcycle : Specification<VehicleObservation>
{
public CanBeObservationOfMotorcycle() : base(
o => o.HasEngine && o.WheelCount == 2,
"It can not be a motorcycle.")
{ }
}
Use them:
[Fact]
public void Can_combine_specs_to_filter_enumerables()
{
var combined = TestSpecs
.AllNumbers
.AndAlso(TestSpecs.OddNumbers)
.And(TestSpecs.Ones.Or(TestSpecs.Threes));
var onesAndThrees = new[] { 1, 2, 3, 4 }.Matching(combined).ToArray();
onesAndThrees.Should().BeEquivalentTo(new[] { 1, 3 });
}
[Theory]
[InlineData(2)]
[InlineData(4)]
public void Or_Should_provide_a_reason_When_not_satisfied(int value)
{
var result = TestSpecs.Ones.Or(TestSpecs.Threes).Eval(value);
result.IsSatisfied.Should().BeFalse();
result.Reasons.Should().BeEquivalentTo("Not a 1.", "Not a 3.");
}
[Fact]
public void Can_handle_non_satisfying_evaluations()
{
var r = TestSpecs.CanBeObservationOfCar.Eval(_fourWheelerWithoutEngine);
r.IsSatisfied.Should().BeFalse();
r.Reasons.Should().BeEquivalentTo("A car must have an engine.");
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.6.1
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|