[Mono-dev] [Patch] NameObjectCollectionBase, HttpCookieCollection
Juraj Skripsky
js at hotfeet.ch
Thu Dec 20 04:38:19 EST 2007
Hi Gert,
I'm attaching my patches, updated as per your suggestions.
- Juraj
On Thu, 2007-12-20 at 10:06 +0100, Gert Driesen wrote:
> Hi Juraj,
>
> I'd advise against using ExpectedException when multiple calls are made in
> the test, as this may lead to false positives.
>
> For example:
>
> [Test]
> [ExpectedException (typeof (ArgumentException))]
> public void CopyTo_NotEnoughSpace ()
> {
> string [] array = new string [4];
> UnitTestNameObjectCollectionBase c = new
> UnitTestNameObjectCollectionBase ();
> c.Add ("1", "mono");
> c.Add ("2", "MoNo");
> c.Add ("3", "mOnO");
> c.Add ("4", "MONO");
> ((ICollection)c).CopyTo (array, 2);
> }
>
> If any of the Add methods would lead to an ArgumentException, the test would
> pass although you explicitly wanted to check if CopyTo resulted in an
> ArgumentException.
>
> I would advise the following code (which is more bloated, yes):
>
> [Test]
> public void CopyTo_NotEnoughSpace ()
> {
> string [] array = new string [4];
> UnitTestNameObjectCollectionBase c = new
> UnitTestNameObjectCollectionBase ();
> c.Add ("1", "mono");
> c.Add ("2", "MoNo");
> c.Add ("3", "mOnO");
> c.Add ("4", "MONO");
> try {
> ((ICollection)c).CopyTo (array, 2);
> Assert.Fail ("#1");
> } catch (ArgumentException ex) {
> Assert.AreEqual (typeof (ArgumentException),
> ex.GetType (), "#2");
> Assert.IsNull (ex.InnerException, "#3");
> Assert.IsNotNull (ex.Message, "#4");
> Assert.IsNull (ex.ParamName, "#5");
> }
> }
>
> This also allows you to perform additional checks (eg. was there an inner
> exception?).
>
> Gert
>
> -----Original Message-----
> From: mono-devel-list-bounces at lists.ximian.com
> [mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf Of Juraj
> Skripsky
> Sent: woensdag 19 december 2007 11:27
> To: mono-devel-list at lists.ximian.com
> Subject: [Mono-dev] [Patch] NameObjectCollectionBase, HttpCookieCollection
>
> Hello,
>
> Attached are three small patches for NameObjectCollectionBase.cs,
> NameObjectCollectionBaseTest.cs and HttpCookieCollection.cs.
>
> All unit tests pass on Mono. Could someone verify that the new unit tests
> work on MS.NET?
>
> May I commit?
>
> - Juraj
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HttpCookieCollection.patch
Type: text/x-patch
Size: 1254 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071220/0b6bdb6b/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NameObjectCollectionBase.patch
Type: text/x-patch
Size: 2507 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071220/0b6bdb6b/attachment-0001.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NameObjectCollectionBaseTest.patch
Type: text/x-patch
Size: 3185 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071220/0b6bdb6b/attachment-0002.bin
More information about the Mono-devel-list
mailing list