Example #1
0
        public void HonorsIgnoreCase(IEnumerable actual)
        {
            var constraint = new UniqueItemsConstraint().IgnoreCase;
            var result     = constraint.ApplyTo(actual);

            Assert.That(result.IsSuccess, Is.False, "{0} should not be unique ignoring case", actual);
        }
 protected override void SetUp()
 {
     Matcher = new UniqueItemsConstraint();
     GoodValues = new object[] { new int[] { 1, 3, 17, -2, 34 }, new object[0] };
     BadValues = new object[] { new int[] { 1, 3, 17, 3, 34 } };
     Description = "all items unique";
 }
Example #3
0
        public void DuplicateItemsTests_RequiresDefaultComparer(IEnumerable items, bool success)
        {
            var constraint = new UniqueItemsConstraint();
            var result     = constraint.ApplyTo(items) as UniqueItemsConstraintResult;

            Assert.That(result, Is.Not.Null);
            Assert.That(result.IsSuccess, Is.EqualTo(success));
        }
Example #4
0
        public void DuplicateItemsTests(IEnumerable items, IEnumerable expectedFailures)
        {
            var constraint = new UniqueItemsConstraint().IgnoreCase;
            var result     = constraint.ApplyTo(items) as UniqueItemsConstraintResult;

            Assert.That(result, Is.Not.Null);
            Assert.That(result.NonUniqueItems, Is.EqualTo(expectedFailures));
        }
Example #5
0
        public void DoesntRespectCultureWhenCasingMatters()
        {
            var constraint = new UniqueItemsConstraint();
            var items      = new[] { "r\u00E9sum\u00E9", "re\u0301sume\u0301" };

            var result = constraint.ApplyTo(items) as UniqueItemsConstraintResult;

            Assert.That(result.IsSuccess, Is.True);
        }
Example #6
0
        public void RespectsCultureWhenCaseIgnored()
        {
            var constraint = new UniqueItemsConstraint().IgnoreCase;
            var items      = new[] { "r\u00E9sum\u00E9", "re\u0301sume\u0301" };

            var result = constraint.ApplyTo(items) as UniqueItemsConstraintResult;

            Assert.That(result.IsSuccess, Is.False);
        }
Example #7
0
        public void SlowPath_TakenWhenSpecialTypes(IEnumerable <object> testData)
        {
            var allData = new List <object>();

            allData.Add(new TestValueType()
            {
                A = 1
            });
            allData.AddRange(testData);

            var items      = new SimpleObjectCollection((IEnumerable <object>)allData);
            var constraint = new UniqueItemsConstraint();
            var stopwatch  = new Stopwatch();

            stopwatch.Start();
            constraint.ApplyTo(items);
            stopwatch.Stop();

            Assert.That(stopwatch.ElapsedMilliseconds, Is.GreaterThanOrEqualTo(50));
        }
 public void SetUp()
 {
     theConstraint = new UniqueItemsConstraint();
     stringRepresentation = "<uniqueitems>";
     expectedDescription = "all items unique";
 }
Example #9
0
 public void SetUp()
 {
     theConstraint        = new UniqueItemsConstraint();
     stringRepresentation = "<uniqueitems>";
     expectedDescription  = "all items unique";
 }