Loading...

nunit-discuss@googlegroups.com

[Prev] Thread [Next]  |  [Prev] Date [Next]

Re: [nunit-discuss] How to use DelayedConstraint Charlie Poole Wed Feb 15 11:00:21 2012

Hi Juan,

On Wed, Feb 15, 2012 at 4:23 AM, Juan Manuel Truppia
<[EMAIL PROTECTED]> wrote:
> It didn't seem clear in the docs to me, we don't have an example
>
> Suppose I have this
>
> Thread.Sleep(65*1000);
> Assert.That(() => foo(),Throws.Nothing);

This means
1. Sleep for 65 seconds
2. call foo()
3. Assert that it didn't throw

> Is this the same as
>
> Assert.That(() => foo(),Throws.Nothing.After(65 * 1000))

This means
1. Wait 65 seconds
2. Call the lambda, which calls foo()
3. Assert that it didn't throw.


So they are essentially the same.

Note that you can also use After with a second argument, the polling
interval, in which case the full 65 second wait may not be needed.
In that case, the method must be one that can be called repeatedly
without causing a problem.

Your use with Throws.Nothing doesn't seem to make a lot of sense,
however. The normal sequence for which we want to use this
constraint is:

1. Take an action
2. Wait a period of time
3. Observe the result

For example,
  worker.Start();
  Assert.That( worker.State, Is.EqualTo(WorkerState.Idle).After(30000);

Charlie

> ???
>
> Cheers
>
> --
> You received this message because you are subscribed to the Google Groups
> "NUnit-Discuss" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/nunit-discuss/-/_l06k5ggf54J.
> To post to this group, send email to [EMAIL PROTECTED]
> To unsubscribe from this group, send email to
> [EMAIL PROTECTED]
> For more options, visit this group at
> http://groups.google.com/group/nunit-discuss?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"NUnit-Discuss" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nunit-discuss?hl=en.