Exemple #1
0
        /// <summary>
        /// Build a collection of constraint (in fact one by expected item)
        /// Pay really attention that CollectionContainsConstraint is expecting one unique item!
        /// So if you cant to check for several items, you need to apply several Constraint (one by expected item)
        /// </summary>
        protected virtual void BuildInternalConstraint()
        {
            NUnitCtr.Constraint ctr = null;
            foreach (var item in Expected)
            {
                var localCtr = new NUnitCtr.CollectionContainsConstraint(StringComparerHelper.Build(item));
                var usingCtr = localCtr.Using(Comparer);

                if (ctr != null)
                {
                    ctr = new AndConstraint(ctr, usingCtr);
                }
                else
                {
                    ctr = usingCtr;
                }
            }

            if (ctr == null)
            {
                ctr = new NUnitCtr.EmptyCollectionConstraint();
            }

            IResolveConstraint exp = ctr;

            InternalConstraint = exp.Resolve();
        }
Exemple #2
0
        protected override NUnitCtr.Constraint BuildInternalConstraint()
        {
            NUnitCtr.Constraint ctr = null;
            foreach (var item in ExpectedItems)
            {
                var localCtr = new NUnitCtr.CollectionContainsConstraint(StringComparerHelper.Build(item));
                var usingCtr = localCtr.Using(Comparer);

                if (ctr != null)
                {
                    ctr = new NUnitCtr.AndConstraint(ctr, usingCtr);
                }
                else
                {
                    ctr = usingCtr;
                }
            }
            return(ctr);
        }
Exemple #3
0
 /// <summary>
 /// Construct a CollectionEquivalentConstraint
 /// </summary>
 /// <param name="expected"></param>
 public EquivalentToConstraint(IEnumerable <string> expected)
     : base(expected)
 {
     InternalConstraint = new CollectionEquivalentConstraint(expected.Select(str => StringComparerHelper.Build(str)).ToList());
 }
Exemple #4
0
 protected override NUnitCtr.Constraint BuildInternalConstraint()
 {
     return(new CollectionSubsetConstraint(ExpectedItems.Select(str => StringComparerHelper.Build(str)).ToList()));
 }
Exemple #5
0
 /// <summary>
 /// Construct a LinkedToConstraint
 /// </summary>
 public LinkedToConstraint(string expected)
     : base()
 {
     InternalConstraint = new CollectionContainsConstraint(StringComparerHelper.Build(expected));
     this.Expected      = expected;
 }