public void TestNullsInComparisonReturnOne() { TestSorter sorter = new TestSorter(3); Assert.AreEqual(3, sorter.Compare(new TestRow(), new TestRow())); Assert.AreEqual(1, sorter.Compare(null, new TestRow())); Assert.AreEqual(1, sorter.Compare(new TestRow(), null)); Assert.AreEqual(1, sorter.Compare(null, null)); }
public void NullObjectsAreTestedAsOne() { TestSorter s = new TestSorter(3); Assert.AreEqual(1, s.Compare(null, null)); Assert.AreEqual(1, s.Compare(new TestRow(), null)); Assert.AreEqual(1, s.Compare(null, new TestRow())); Assert.AreEqual(3, s.Compare(new TestRow(), new TestRow())); }
public void MinusOneResultDoNotCallStableSorter() { TestSorter s = new TestSorter(-1); var mock = new Mock <IComparer>(MockBehavior.Strict); s.StableSorter = mock.Object; Assert.AreEqual(-1, s.Compare(new TestRow(), new TestRow())); mock.Verify(m => m.Compare(It.IsAny <TestRow>(), It.IsAny <TestRow>()), Times.Never()); }
public void ZeroResultDoesCallStableSorterAndReturnsTheStableSorterValue() { TestSorter s = new TestSorter(0); var mock = new Mock <IComparer>(MockBehavior.Strict); mock.Setup(m => m.Compare(It.IsAny <TestRow>(), It.IsAny <TestRow>())).Returns(3); s.StableSorter = mock.Object; Assert.AreEqual(3, s.Compare(new TestRow(), new TestRow())); mock.Verify(m => m.Compare(It.IsAny <TestRow>(), It.IsAny <TestRow>()), Times.Once()); }
public void TestDefaultConstructorUsesAscending() { TestSorter sorter = new TestSorter(3); Assert.AreEqual(3, sorter.Compare(new TestRow(), new TestRow())); }
public void TestDirectionConstructorDescending() { TestSorter sorter = new TestSorter(ListSortDirection.Descending, 3); Assert.AreEqual(-3, sorter.Compare(new TestRow(), new TestRow())); }