← Back to team overview

nunit-core team mailing list archive

[Bug 1099517] Re: Assert.That with Throws should allow asserting on lambda property

 

** Changed in: nunitv2
       Status: New => Triaged

** Changed in: nunitv2
   Importance: Undecided => Medium

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

Title:
  Assert.That with Throws should allow asserting on lambda property

Status in NUnit V2 Test Framework:
  Triaged

Bug description:
  To assert a property name, one can use the following
      Assert.That (testDelegate, Throws.ArgumentException.With.Property("ParamName").EqualTo ("name"));
  or this one, as a refactor-friendly way
      Assert.That (testDelegate, Throws.ArgumentException.And.Matches<ArgumentException> (x => x.ParamName == "name"));
  It works but the error text reported when the assert is not satisfied is rather generic:
       Expected: <System.ArgumentException> and value matching lambda expression

  There should be an easier way to express the intent and have a better error message, something like:
       Assert.That (testDelegate, Throws.ArgumentException.And.Property(ex => ex.ParamName).EqualTo ("name"));

  with the error reporting:
       Expected: Property lambda ex.ParamName with value "name"
       but got
       Property lambda ex.ParamName with value "myParam"

  TestCaseData migh also benefit from this if it implemented the lambda
  property functionality.

  As discussed here: https://groups.google.com/forum/#!topic/nunit-
  discuss/Fg0oFzR8owE

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


References