Exemplo n.º 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);
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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));
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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));
        }