Tests: Assertion fails in a anonymous initialization method

A

Armin Galliker

Hi

I wrote a test for a workflow. Unfortunately my assertions in the
eventhandler which I set up during initialization, fail in every case...
What's the problem??

[TestInitialize()]
public void MyTestInitialize() {

workflowRuntime.WorkflowCompleted += delegate(object
sender,WorkflowCompletedEventArgs e) {
completedArgs = e;
waitHandle.Set();
Assert.Fail("Error"); // cause a unhandled
AssertFaildException --> Assert.Fail failed.
};

}

Thanks!
 
A

Armin Galliker

Hi Pete
I don't understand your question. Assert.Fail() always fails, by
definition. Every time you hit that line of code, you'll get an exception.

Why are you surprised that that happens?

I know that. My problem isn't the fact that Assert.Fail() fails, but rather
that the exception isn't handled... Normally I don't have to handle the
AssertFailedException by myself. I think the problem is caused that the
method is called in the event handler (WorkflowCompleted).

As a matter of fact my test succeed and I think that's because my exception
(--> Assert.Fail) isn't handled as is has to.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top