Re: Assert.Throws Syntax

"Kelly Anderson" <[email protected]> Fri, 15 Aug 2008 10:54:12 -0600
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <[email protected]>
Ok, that helped some... I tried this and got closer...

Assert.Throws<CommBrokerNotInjected>( delegate { Hardware.PhysicalHardware; } );

But now I get:

Error	6	Only assignment, call, increment, decrement, and new object
expressions can be used as a statement	C:\src\HardwareTests.cs

So, I guess accessing a static property is not considered a call for
purposes of anonymous delegates?

-Kelly

On Thu, Aug 14, 2008 at 10:53 AM, Charlie Poole
<[email protected]> wrote:
> Your initial curly brace is in the wrong place.
>
> It should be
>> Assert.Throws<CommBrokerNotInjected>( delegate {
>> Hardware.PhysicalHardware } );
>
> Of course, I'm assuming that PhysicalHardware is
> a static property of the Hardware class.
>
> Charlie
>
>> -----Original Message-----
>> From: [email protected]
>> [mailto:[email protected]] On Behalf
>> Of Kelly Anderson
>> Sent: Thursday, August 14, 2008 9:19 AM
>> To: [email protected]
>> Subject: [Nunit-users] Assert.Throws Syntax
>>
>> This syntax comes from the documentation...
>>
>> Assert.Throws<CommBrokerNotInjected>( { delegate
>> Hardware.PhysicalHardware } );
>>
>> Is this using C# 3.0 syntax? It doesn't compile on my 2.0
>> compiler, so I just wondered if it's using a 2008 syntax.
>>
>> -Kelly
>>
>> --------------------------------------------------------------
>> -----------
>> This SF.Net email is sponsored by the Moblin Your Move
>> Developer's challenge Build the coolest Linux based
>> applications with Moblin SDK & win great prizes Grand prize
>> is a trip for two to an Open Source event anywhere in the
>> world http://moblin-contest.org/redirect.php?banner_id=100&url=/
>> _______________________________________________
>> Nunit-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/nunit-users
>>
>
>
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/