On Wed, Feb 15, 2012 at 4:23 AM, Juan Manuel Truppia
<jmtr...@gmail.com> 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 nunit-...@googlegroups.com.
> To unsubscribe from this group, send email to
> nunit-discus...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/nunit-discuss?hl=en.
Hi Juan,
On Wed, Feb 15, 2012 at 4:23 AM, Juan Manuel Truppia
Charlie, I didn't get the same results with this.1- With the sleep, I first wait, and then do the action2- With the After constraint, I first do the action, and then sleep (waiting to check if an exception is raised)
I required behavior number 1, so I had to go with the Sleep. Does NUnit provide some way to implement behavior 1?
To view this discussion on the web visit https://groups.google.com/d/msg/nunit-discuss/-/zZkYUN272mIJ.
To unsubscribe from this group, send email to nunit-discus...@googlegroups.com.