Re: Assert.Throws Syntax
"Charlie Poole" <[email protected]> Fri, 15 Aug 2008 11:57:15 -0700
| Newsgroups | gmane.comp.windows.dotnet.nunit.user |
|---|---|
| Message-ID | <009b01c8ff08$bd074290$6401a8c0@ferrari> |
Hi Kelly,
Properties are not considered calls. You'll get the same error if you
try to put
Hardware.PhysicalHardware;
anyplace in your program as a statement.
One workaround is to assign it to something, which
makes it a statement. another is to create a method
like
void Call(object o) { }
and write
delegate { Call( Hardware.PysicalHardware ); }
If it were GetPhysicalHardware() this would be easier.
Charlie
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf
> Of Kelly Anderson
> Sent: Friday, August 15, 2008 9:54 AM
> To: [email protected]
> Subject: Re: [Nunit-users] Assert.Throws Syntax
>
> 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=/
> _______________________________________________
> 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=/