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

Gert Driesen gert.driesen at pandora.be
Wed Jul 2 10:15:46 EDT 2003


----- 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.

Gert




More information about the Mono-devel-list mailing list