473,657 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Tests: Assertion fails in a anonymous initialization method

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 MyTestInitializ e() {

workflowRuntime .WorkflowComple ted += delegate(object
sender,Workflow CompletedEventA rgs e) {
completedArgs = e;
waitHandle.Set( );
Assert.Fail("Er ror"); // cause a unhandled
AssertFaildExce ption -- Assert.Fail failed.
};

}

Thanks!
Jun 27 '08 #1
4 2034
On Wed, 23 Apr 2008 00:51:01 -0700, Armin Galliker
<Ar***********@ discussions.mic rosoft.comwrote :
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
Jun 27 '08 #2
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
AssertFailedExc eption by myself. I think the problem is caused that the
method is called in the event handler (WorkflowComple ted).

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.

Jun 27 '08 #3
On Thu, 24 Apr 2008 06:21:00 -0700, Armin Galliker
<Ar***********@ discussions.mic rosoft.comwrote :
>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...
Sigh. Can you at least see how a subject of "Assertion fails" and
comments in your original post like "my assertions...fa il in every case"
were counter-productive with respect to describing your problem?
Normally I don't have to handle the
AssertFailedExc eption 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 (WorkflowComple ted).
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
Jun 27 '08 #4
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...9-c04863b02e6f

Armin
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3161
by: Todd Miller | last post by:
Hi, I recently discovered an assertion failure in the Python garbage collection system when scripts using our C extension (numarray) exit. The assertion is activated for Pythons configured using --with-pydebug. I have a feeling I may be doing something wrong with garbage collection support for some of our c types, but I'm not sure exactly what. Here is the assertion output:
6
595
by: Cormac | last post by:
Hi everyone, I'm writing Pure Data externals in C++ using Ms Visual C++ 7.0 and Windows2000. I'm running motions sensor hardware so there's a bit of real time data processing involved. When I'm running my objects in Pure Data, I get an assertion failure after a few seconds of running the motion sensors and I can't seem to get rid of it. The error occurs in the expression _CrtCheckMemory(). Could anyone provide some possible solutions?
1
3768
by: Udi | last post by:
Hi, I'm new to NUnit and C#. I've created a list of tests for my module and everything works fine. However, there are several tests that depend on other, and must be run after them. is it possile to control the order of the tests execution through NUnit? Thanks!
4
13560
by: ellieong | last post by:
When i try to run my program, i get this error "debug assertion failed!" and it's caused by this file called "afxtempl.h" at line 262. isn't this header file provided by c++? so how can i get rid of this problem. if i click ignore i can see the output, but how can i get rid of such an error msg?
2
2281
by: um | last post by:
When the POSIX pthreads library for w32 release 2-2-0 (http://sources.redhat.com/pthreads-win32/) is compiled with VC++6 then it compiles and passes all the benchmark tests in the subdirectory "tests". Also, VC++ 2005 beta 1 compiles the tests fine, but here the following tests fail in execution: # semaphore1.pass \ # condvar2.pass \ # condvar2_1.pass \ # mutex8.pass \
3
3570
by: Belebele | last post by:
Suppose I want to test several implementations of the same protocol (interface with clearly defined semantics) using cppUnit. How to reuse the test that checks the semantics? Take, for example, the simple SetterGetter interface and the even simpler implementations Impl1 and Impl2. class SetterGetter { SetterGetter& operator=(SetterGetter const& ); // Not Implemented
2
1668
by: titan.nyquist | last post by:
I need to initialize data to be stored in a static class (for all my code to see), but I'm lost on how to do so. If I use the class constructor, what if it fails? I am reading it information from files that (could potentially) not exist. If it throws an exception, it could be thrown wherever the first access to the class is, which is undetermined. This seems like a bad idea. Furthurmore, the data initialization code should be run at...
12
2702
by: =?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?= | last post by:
Hi, I need to initialize my class level dictionary (in .Net 2.0). I wanted to make it inline and employ anonymous methods as I do not use this code for anything else. Something similar to the following: private static Dictionary<string, field_fields = delegate() { Dictionary<string, fieldresult = new Dictionary<string, field>(); result.Add("Application", new field("Application", "AppName"));
270
8040
by: Jordan | last post by:
Hi everyone, I'm a big Python fan who used to be involved semi regularly in comp.lang.python (lots of lurking, occasional posting) but kind of trailed off a bit. I just wrote a frustration inspired rant on my blog, and I thought it was relevant enough as a wider issue to the Python community to post here for your discussion and consideration. This is not flamebait. I love Python, and I'm not out to antagonise the community. I also...
0
8394
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8306
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4152
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.