public void IsOrdered_HandlesCustomComparison()
        {
            AlwaysEqualComparer comparer = new AlwaysEqualComparer();

            Assert.That(new[] { new object(), new object() }, Is.Ordered.Using(comparer));
            Assert.That(comparer.CallCount, Is.GreaterThan(0), "TestComparer was not called");
        }
Exemplo n.º 2
0
        public void IsOrdered_Handles_custom_comparison()
        {
            ICollection collection = new SimpleObjectCollection(new object(), new object());

            AlwaysEqualComparer comparer = new AlwaysEqualComparer();

            Assert.That(collection, Is.Ordered.Using(comparer));
            Assert.That(comparer.Called, "TestComparer was not called");
        }
Exemplo n.º 3
0
        public void IsOrdered_Handles_custom_comparison()
        {
            ArrayList al = new ArrayList();
            al.Add(new object());
            al.Add(new object());

            AlwaysEqualComparer comparer = new AlwaysEqualComparer();
            Assert.That(al, Is.Ordered.Using(comparer));
            Assert.That(comparer.Called, "TestComparer was not called");
        }
        public void MultipleComparersUsedInDifferentSteps()
        {
            var comparer1  = new TestComparer();
            var comparer2  = new AlwaysEqualComparer();
            var collection = new[] { new TestClass3("XYZ", 2), new TestClass3("ABC", 42), new TestClass3("ABC", 1) };

            Assert.That(collection, Is.Ordered.By("A").Using(comparer1).Then.By("B").Using(comparer2));

            // First comparer is called for every pair of items in the collection
            Assert.That(comparer1.CallCount, Is.EqualTo(2), "First comparer should be called twice");

            // Second comparer is only called where the first property matches
            Assert.That(comparer2.CallCount, Is.EqualTo(1), "Second comparer should be called once");
        }
        public void MultipleComparersUsedInDifferentSteps()
        {
            var comparer1 = new TestComparer();
            var comparer2 = new AlwaysEqualComparer();
            var collection = new[] { new TestClass3("XYZ", 2), new TestClass3("ABC", 42), new TestClass3("ABC", 1) };

            Assert.That(collection, Is.Ordered.By("A").Using(comparer1).Then.By("B").Using(comparer2));

            // First comparer is called for every pair of items in the collection
            Assert.That(comparer1.CallCount, Is.EqualTo(2), "First comparer should be called twice");

            // Second comparer is only called where the first property matches
            Assert.That(comparer2.CallCount, Is.EqualTo(1), "Second comparer should be called once");
        }
 public void IsOrdered_HandlesCustomComparison()
 {
     AlwaysEqualComparer comparer = new AlwaysEqualComparer();
     Assert.That(new[] { new object(), new object() }, Is.Ordered.Using(comparer));
     Assert.That(comparer.CallCount, Is.GreaterThan(0), "TestComparer was not called");
 }
        public void IsOrdered_Handles_custom_comparison()
        {
            var al = new List<object>();
            al.Add(new object());
            al.Add(new object());

            AlwaysEqualComparer comparer = new AlwaysEqualComparer();
            Assert.That(al, Is.Ordered.Using(comparer));
            Assert.That(comparer.Called, "TestComparer was not called");
        }