Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / April 2008

Tip: Looking for answers? Try searching our database.

Tests: Assertion fails in a anonymous initialization method

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Armin Galliker - 23 Apr 2008 08:51 GMT
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!
Peter Duniho - 23 Apr 2008 17:52 GMT
> 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??

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?

Pete
Armin Galliker - 24 Apr 2008 14:21 GMT
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.
Peter Duniho - 24 Apr 2008 18:21 GMT
>> I don't understand your question.  Assert.Fail() always fails, by
>> definition.  Every time you hit that line of code, you'll get an  
[quoted text clipped - 5 lines]
> rather
> that the exception isn't handled...

Sigh.  Can you at least see how a subject of "Assertion fails" and  
comments in your original post like "my assertions...fail in every case"  
were counter-productive with respect to describing your problem?

> Normally I don't have to handle the
> AssertFailedException by myself.

What do you mean "normally"?  In what situation do you not have to handle  
the exception yourself?

> I think the problem is caused that the
> method is called in the event handler (WorkflowCompleted).

It certainly could be.  It depends on how the event handler is being  
executed.

Presumably there's some aspect about the question that is specific to this  
"test for a workflow", and since I'm not familiar with the use of  
"workflow" in the context of .NET, I don't fully understand the question.

Frankly, at this point I would recommend that you start a whole new  
thread, and put a subject that actually describes what the issue is,  
including the specific area of .NET in which you're working (i.e. assuming  
"workflow" has a specific meaning here, be very specific in your subject  
about the fact that you're using this "workflow", and make sure you use  
the precise terminology/type/etc. that .NET would use).

As things stand now, the few people who might understand the context of  
"workflow" may well have just skipped past the thread, because there's  
nothing immediately visible in the thread that would alert them to the  
fact that it's something they might know something about.

Finally, given the apparent esoteric nature of the question, you should  
probably post a concise-but-complete code sample that reliably  
demonstrates the problem.  The sample should demonstrate both the case  
that works as you expect, as well as the case that doesn't.

Pete
Armin Galliker - 25 Apr 2008 08:48 GMT
Hi Pete

I apologize for my unclear question. You're absolutely right. Nevertheless,
I thank you for your comments. As you recommended I've opened a new thread:

http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?&lang=en&cr=U
S&guid=&sloc=en-us&dg=microsoft.public.dotnet.languages.csharp&p=1&tid=936cd268-
b3b2-4d1d-ac69-c04863b02e6f&mid=936cd268-b3b2-4d1d-ac69-c04863b02e6f


Armin

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.