← Back to team overview

nunit-core team mailing list archive

[Bug 674860] [NEW] Using() modifier missing on NUnit.Framework.Contains.Item()

 

Public bug reported:

There is a Using() modifier on NUnit.Framework.Is.EqualTo() (I'm using
v2.5.8,) but I'd like to have one on NUnit.Framework.Contains.Item(),
too. Here's what you'd have to do.

Make CollectionItemsEqualConstraint.comparer protected:
<    public abstract class CollectionItemsEqualConstraint :
CollectionConstraint
<    {
<        private NUnitEqualityComparer comparer =
NUnitEqualityComparer.Default;
-------

>    public abstract class CollectionItemsEqualConstraint : CollectionConstraint
>    {
>        protected NUnitEqualityComparer comparer = NUnitEqualityComparer.Default;

Add the Using modifier to CollectionContainsConstraint:
>        /// <summary>
>        /// Flag the constraint to use the supplied Comparison object.
>        /// </summary>
>        /// <param name="comparer">The Comparison<T> object to use.</param>
>        /// <returns>Self.</returns>
>        public CollectionContainsConstraint Using<T>(Comparison<T> comparer)
>        {
>            this.comparer.ExternalComparer = EqualityAdapter.For(comparer);
>            return this;
>        }

Variants go similar.

Narrow the return type of Contains.Item() so the new modifier becomes
accessible:

>        /// <summary>
>        /// Creates a new CollectionContainsConstraint.
>        /// </summary>
>        /// <param name="item">The item that should be found.</param>
>        /// <returns>A new CollectionContainsConstraint</returns>
>        public static CollectionContainsConstraint Item(object item)
>        {
>            return new CollectionContainsConstraint(item);
>        }

** Affects: nunitv2
     Importance: Undecided
         Status: New

-- 
Using() modifier missing on NUnit.Framework.Contains.Item()
https://bugs.launchpad.net/bugs/674860
You received this bug notification because you are a member of NUnit
Developers, which is subscribed to NUnit V2.

Status in NUnit V2 Test Framework: New

Bug description:
There is a Using() modifier on NUnit.Framework.Is.EqualTo() (I'm using
v2.5.8,) but I'd like to have one on NUnit.Framework.Contains.Item(),
too. Here's what you'd have to do.

Make CollectionItemsEqualConstraint.comparer protected:
<    public abstract class CollectionItemsEqualConstraint :
CollectionConstraint
<    {
<        private NUnitEqualityComparer comparer =
NUnitEqualityComparer.Default;
-------

>    public abstract class CollectionItemsEqualConstraint : CollectionConstraint
>    {
>        protected NUnitEqualityComparer comparer = NUnitEqualityComparer.Default;

Add the Using modifier to CollectionContainsConstraint:
>        /// <summary>
>        /// Flag the constraint to use the supplied Comparison object.
>        /// </summary>
>        /// <param name="comparer">The Comparison<T> object to use.</param>
>        /// <returns>Self.</returns>
>        public CollectionContainsConstraint Using<T>(Comparison<T> comparer)
>        {
>            this.comparer.ExternalComparer = EqualityAdapter.For(comparer);
>            return this;
>        }

Variants go similar.

Narrow the return type of Contains.Item() so the new modifier becomes
accessible:

>        /// <summary>
>        /// Creates a new CollectionContainsConstraint.
>        /// </summary>
>        /// <param name="item">The item that should be found.</param>
>        /// <returns>A new CollectionContainsConstraint</returns>
>        public static CollectionContainsConstraint Item(object item)
>        {
>            return new CollectionContainsConstraint(item);
>        }





Follow ups

References