public void Clients_DoNotHaveToCareAboutNulls() { var notNull = new ComparisonSubject("a", 1, 1m); var chainable = new SelectorComparer <ComparisonSubject, int>(s => s.Property2); Assert.That(chainable.Compare(notNull, null), Is.GreaterThan(0)); Assert.That(chainable.Compare(null, notNull), Is.LessThan(0)); Assert.That(chainable.Compare(null, null), Is.EqualTo(0)); }
public void Compare_ComparedTheSelectedProperty_HonoringDirection() { var subject = new SelectorComparer <ComparisonSubject, int>(s => s.Property2, Direction.Ascending); Assert.That(subject.Compare(ComparisonSubject.One, ComparisonSubject.Two), Is.LessThan(0)); subject = new SelectorComparer <ComparisonSubject, int>(s => s.Property2, Direction.Descending); Assert.That(subject.Compare(ComparisonSubject.One, ComparisonSubject.Two), Is.GreaterThan(0)); }
public void Explore() { IComparer <ComparisonSubject> subject = new SelectorComparer <ComparisonSubject, int>(s => s.Property2, Direction.Descending); Assert.That(subject.Compare(ComparisonSubject.One, ComparisonSubject.Two), Is.GreaterThan(0)); IComparer <ComparisonSubject> by3Then2Desc = new SelectorComparer <ComparisonSubject, decimal>(s => s.Property3) .Then(s => s.Property2, Direction.Descending); by3Then2Desc = Cmp <ComparisonSubject> .By(s => s.Property3) .Then(s => s.Property2, Direction.Descending); }