[Mono-devel-list] Patch to use ExpectedException in Test XmlTextWriterTests

Martin Willemoes Hansen mwh at sysrq.dk
Wed Jul 2 18:29:55 EDT 2003


On Wed, 2003-07-02 at 16:15, Gert Driesen wrote:
> ----- Original Message ----- 
> From: "Martin Willemoes Hansen" <mwh at sysrq.dk>
> To: <mono-devel-list at lists.ximian.com>
> Sent: Wednesday, July 02, 2003 3:20 PM
> Subject: [Mono-devel-list] Patch to use ExpectedException in Test
> XmlTextWriterTests
> 
> 
> > Hi!
> >
> > I changed mcs/class/System.XML/Test/System.Xml/XmlTextWriterTests to
> > make use of the ExpectedExceptionAttribute
> >
> > Okay to commit?
> 
> I don't think it's safe to change
> 
> [Test]
> public void CommentInvalid ()
> {
>    try {
>     xtw.WriteComment("foo-");
>     Fail("Should have thrown an ArgumentException.");
>    }
>    catch (ArgumentException) { }
> 
>    try {
>     xtw.WriteComment("foo-->bar");
>     Fail("Should have thrown an ArgumentException.");
>    }
>    catch (ArgumentException) { }
>   }
> 
> to
> 
> [Test]
> [ExpectedException (typeof (ArgumentException))]
> public void CommentInvalid ()
> {
>    xtw.WriteComment("foo-");
>    xtw.WriteComment("foo-->bar");
> }
> 
> The first test will only succeed if both method calls throw an
> ArgumentException, while the second test will succeed if either of these
> method calls will throw an ArgumentException.

You are right!, Ive fixed it. Thanks

> Gert
-- 
Martin Willemoes Hansen

--------------------------------------------------------
E-Mail	mwh at sysrq.dk	Website	mwh.sysrq.dk
IRC     MWH, freenode.net
--------------------------------------------------------               





More information about the Mono-devel-list mailing list