← Back to team overview

nunit-core team mailing list archive

[Bug 984040] Re: Has.Attribute error

 

The design of NUnit requires the operator to return a constraint object,
combining the two constraints. This is not possible using logical or,
since || cannot be overridden. It's possible to simulate an override of
operator ||, by specifying an implicit conversion of the constraint to
boolean, but that would give a boolean result rather than a constraint.
We need a constraint because the constraint object knows how to provide
an error message.

-- 
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.
https://bugs.launchpad.net/bugs/984040

Title:
  Has.Attribute error

Status in NUnit V2 Test Framework:
  Triaged

Bug description:
  NUnit 2.5.10 with gui

  The following line does not work:
  Assert.That(GetType(), Has.Attribute<Attr1>() | Has.Attribute<Attr2>());

  Compiler gives an error like "cannot use operator | with two ResolvableConstraintExpressions".
  Would be nice if this will compile in future.

  But this works:
  Assert.That(GetType(), Has.Attribute<Attr1>().Or.Attribute<Attr2>());

To manage notifications about this bug go to:
https://bugs.launchpad.net/nunitv2/+bug/984040/+subscriptions


References