← Back to team overview

nunit-core team mailing list archive

[Bug 890129] Re: DelayedConstraint doesn't appear to poll properties of objects

 

After giving it some thought, I decided

1) It's intuitive to expect the provided example to work.

2) In those cases that will not work due to prior evaluation of the
argument, polling will not change the outcome but simply cause a bit of
overhead.

3) It's simplest to poll in all cases where a polling interval is
provided (i.e. do what the user said to do).

4) In future, it might be useful to give a warning when the actual value
is a simple type.

Charlie

** Changed in: nunitv2
       Status: New => In Progress

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

** Changed in: nunitv2
     Assignee: (unassigned) => Charlie Poole (charlie.poole)

** Changed in: nunitv2
    Milestone: None => 2.6.0b2

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

Title:
  DelayedConstraint doesn't appear to poll properties of objects

Status in NUnit V2 Test Framework:
  Fix Committed

Bug description:
  Using 2.5.10.11092.

  I've just been exploring the new (to me) fluent/constraints syntax, specifically the After() constraint and am very impressed.
  I've already learnt not to pass by value (!), however, I thought that a pass-by-reference should be ok.

  For example:
           var worker = new BackgroundWorker();
           var list = new List<int>();
           worker.RunWorkerCompleted += delegate { list.Add(1); };
           worker.DoWork += delegate { Thread.Sleep(1); };
           worker.RunWorkerAsync();
           Assert.That(list, Has.Count.EqualTo(1).After(5000, 100));

  The documentation states that its "intended use is with delegates and references", so I'd expect the 'list' object reference to be polled, and after about 1 second, for the constraint to pass.
  However, I have to wait for the full 5 seconds before the test succeeds.

  The obvious work around is to convert the 'list' object to a delegate:
           Assert.That(() => list, Has.Count.EqualTo(1).After(5000, 100));

  This works fine, and still look ok (to me).

  However, I wondered if this is deliberate or unavoidable behaviour or
  just a bug...

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


References