nunit-core team mailing list archive
-
nunit-core team
-
Mailing list archive
-
Message #01445
[Bug 689079] Re: CollectionAssert.Contains checks against entire object, not contents
Your assert states that the collection contains the an object which *is*
the Bitmap System.Type - not an instance of that type.
It would work if the list contained.
{ typeof(int), typeof(string), typeof(Bitmap) }
To test that the collection contains at least one object of type bitmap, you
can't use CollectionAssert because it's modeled after and limited to the
capabilities of Microsoft's CollectionAssert.
However, you can use NUnit's constraint-based syntax, as follows...
Assert.That(sourceImages, Has.Some.TypeOf<Bitmap>()); *
or even better
Assert.That(sourceImages,
Has.Count.GreaterThan(0).And.All.TypeOf<Bitmap>()); *
Charlie
* Beware: this is mail list code!
On Sat, Dec 11, 2010 at 1:39 PM, Koen De Groote
<689079@xxxxxxxxxxxxxxxxxx> wrote:
> Public bug reported:
>
> Here's a piece of code:
>
> CollectionAssert.Contains(sourceImages, typeof(Bitmap));
>
>
> What I expect this to do, is to check if the Generic List "sourceImages" contains at least one Bitmap element.
>
> "Does sourceImages contain an object that is type Bitmap?". That's what
> I see being tested here.
>
> However, I am receiving this:
>
> http://i.imgur.com/IA7ii.png
>
> This is using NUnit-2.5.9.10320
>
> ** Affects: nunitv2
> Importance: Undecided
> Status: New
>
> --
> You received this bug notification because you are a member of NUnit
> Developers, which is subscribed to NUnit V2.
> https://bugs.launchpad.net/bugs/689079
>
> Title:
> CollectionAssert.Contains checks against entire object, not contents
>
** Changed in: nunitv2
Status: New => Won't Fix
--
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.
https://bugs.launchpad.net/bugs/689079
Title:
CollectionAssert.Contains checks against entire object, not contents
Status in NUnit V2 Test Framework:
Won't Fix
Bug description:
Here's a piece of code:
CollectionAssert.Contains(sourceImages, typeof(Bitmap));
What I expect this to do, is to check if the Generic List "sourceImages" contains at least one Bitmap element.
"Does sourceImages contain an object that is type Bitmap?". That's what I see being tested here.
However, I am receiving this:
http://i.imgur.com/IA7ii.png
This is using NUnit-2.5.9.10320
References