예제 #1
0
 public void CompareChainCanCompareNullables()
 {
     Assert.AreEqual(
         0,
         CompareChain.Of(new { foo = (int?)1 }, new { foo = (int?)1 })
         .Value(it => it.foo)
         .Result
         );
     Assert.AreEqual(
         -1,
         CompareChain.Of(new { foo = (int?)null }, new { foo = (int?)1 })
         .Value(it => it.foo)
         .Result
         );
     Assert.AreEqual(
         1,
         CompareChain.Of(new { foo = (int?)1 }, new { foo = (int?)null })
         .Value(it => it.foo)
         .Result
         );
     Assert.AreEqual(
         -1,
         CompareChain.Of(new { foo = (int?)1 }, new { foo = (int?)2 })
         .Value(it => it.foo)
         .Result
         );
     Assert.AreEqual(
         1,
         CompareChain.Of(new { foo = (int?)2 }, new { foo = (int?)1 })
         .Value(it => it.foo)
         .Result
         );
 }
예제 #2
0
 public void CompareChainReturnsFirstNonZeroDefaultComparerResult()
 {
     Assert.AreEqual(
         -1,
         CompareChain.Of(new { foo = "foo", bar = "bar" }, new { foo = "foo1", bar = "bar" })
         .Value(it => it.foo)
         .Value(it => it.bar)
         .Result
         );
     Assert.AreEqual(
         1,
         CompareChain.Of(new { foo = "foo", bar = "bar1" }, new { foo = "foo", bar = "bar" })
         .Value(it => it.foo)
         .Value(it => it.bar)
         .Result
         );
     Assert.AreEqual(
         0,
         CompareChain.Of(new { foo = "foo", bar = "bar" }, new { foo = "foo", bar = "bar" })
         .Value(it => it.foo)
         .Value(it => it.bar)
         .Result
         );
 }
예제 #3
0
 public void CompareChainStartsAtZero()
 {
     Assert.AreEqual(0, CompareChain.Of("foo", "bar").Result);
 }