A
Armin Galliker
Hi
I've got an unexpected error in a unit test. I want to test a activity from
Windows Workflow Foundation (WF).
First, I executed the test outside of the activity just in the test-init
method. In this case all works fine:
[TestInitialize()]
public void TestInitialize() {
Assert.IsFalse(true); // test should always fail
}
--> Result in the Test-Result window is as expected: Failed. Assert.IsFalse
failed.
Subsequently, I tried to do the same test in the event handler of my
workflow activity:
[TestInitialize()]
public void MatchingTestBaseInitialize() {
workflowRuntime = new WorkflowRuntime();
workflowRuntime.WorkflowCompleted += delegate(object
sender,WorkflowCompletedEventArgs e) {
Assert.IsFalse(true)
waitHandle.Set();
};
// other event handlers
}
--> Result in the Test-Result window is NOT as expected: Passed.
I stepped through the code:
- at the assertion Assert.IsFalse(true) I've got an exception
(AssertFailedException was unhandled by user code)
- after a waitHandle timeout in my activity expired the test ends and
because there is no other assertion the test passes
Why does this happen? I expected the same result as in the first case...
Should I handle the AssertFailedException by myself even though I didn't
handled it in the first case?
I've got an unexpected error in a unit test. I want to test a activity from
Windows Workflow Foundation (WF).
First, I executed the test outside of the activity just in the test-init
method. In this case all works fine:
[TestInitialize()]
public void TestInitialize() {
Assert.IsFalse(true); // test should always fail
}
--> Result in the Test-Result window is as expected: Failed. Assert.IsFalse
failed.
Subsequently, I tried to do the same test in the event handler of my
workflow activity:
[TestInitialize()]
public void MatchingTestBaseInitialize() {
workflowRuntime = new WorkflowRuntime();
workflowRuntime.WorkflowCompleted += delegate(object
sender,WorkflowCompletedEventArgs e) {
Assert.IsFalse(true)
waitHandle.Set();
};
// other event handlers
}
--> Result in the Test-Result window is NOT as expected: Passed.
I stepped through the code:
- at the assertion Assert.IsFalse(true) I've got an exception
(AssertFailedException was unhandled by user code)
- after a waitHandle timeout in my activity expired the test ends and
because there is no other assertion the test passes
Why does this happen? I expected the same result as in the first case...
Should I handle the AssertFailedException by myself even though I didn't
handled it in the first case?