Feature request: Generic constraint model
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
NUnit Framework |
Triaged
|
Wishlist
|
Unassigned |
Bug Description
[Issue now tracked at https:/
For NUnit v3, a fully generic constraint system (i.e., the Constraint and ConstraintExpre
The classic constraint builders Is and Has would instantiate the T (and TElement) with System.Object, so that "Assert.That (myValue, Is.EqualTo (10))" would cause an EqualConstraint
Is.TypeOf<T>, Is.AssignableTo<T>, and Is.InstanceOf<T> would return their respective constraints parameterized with the given T, so that "Assert.That (myValue, Is.TypeOf<
For full type inference support, a new Assert.That syntax could be provided that binds the T to the actual type of the value passed to the Assert method:
public static void That<T> (T actualValue, Func<ResolveCon
and
public static void That<TElement> (IEnumerable<
This would allow code such as the following to be written in a typesafe way without needing to repeat the type:
Assert.That (myVariable, v => v.EqualTo (42));
Assert.That (myCollection, c => c.EquivalentTo (new[] { 1, 2, 3 }));
Assert.That (myCollection, c => c.Member (3));
affects: | nunitv2 → nunit-3.0 |
tags: | added: feature framework |
Changed in nunit-3.0: | |
status: | New → Triaged |
importance: | Undecided → Wishlist |
description: | updated |
tags: | added: github |