示例#1
0
        public void Find_should_return_null_for_non_registered_type()
        {
            var customComparers = new CustomComparers();
            var comparer        = customComparers.Find(typeof(Foo));

            Assert.IsNull(comparer);
        }
示例#2
0
        public void IsRegisteredFor_should_return_true_for_registered_type()
        {
            var customComparers = new CustomComparers();

            customComparers.Register <Foo>((x, y) => x.Value.CompareTo(y.Value));
            Comparison comparer = customComparers.Find(typeof(Foo));

            Assert.IsNotNull(comparer);
        }
示例#3
0
        public void Equals_ok(int foo1, int foo2, int expectedSign)
        {
            var customComparers = new CustomComparers();

            customComparers.Register <Foo>((x, y) => x.Value.CompareTo(y.Value));
            Comparison comparer   = customComparers.Find(typeof(Foo));
            int        actualSign = comparer(new Foo(foo1), new Foo(foo2));

            Assert.AreEqual(expectedSign, actualSign, (x, y) => Math.Sign(x) == Math.Sign(y));
        }
示例#4
0
        public void Register_and_unregister_ok()
        {
            var customComparers = new CustomComparers();

            customComparers.Register <Foo>((x, y) => x.Value.CompareTo(y.Value));
            customComparers.Unregister <Foo>();
            var comparer = customComparers.Find(typeof(Foo));

            Assert.IsNull(comparer);
        }
示例#5
0
        public void Find_with_null_type_should_throw_exception()
        {
            var customComparers = new CustomComparers();

            customComparers.Find(null);
        }
 public void IsRegisteredFor_should_return_true_for_registered_type()
 {
     var customComparers = new CustomComparers();
     customComparers.Register<Foo>((x, y) => x.Value.CompareTo(y.Value));
     Comparison comparer = customComparers.Find(typeof(Foo));
     Assert.IsNotNull(comparer);
 }
 public void Find_should_return_null_for_non_registered_type()
 {
     var customComparers = new CustomComparers();
     var comparer = customComparers.Find(typeof(Foo));
     Assert.IsNull(comparer);
 }
 public void Find_with_null_type_should_throw_exception()
 {
     var customComparers = new CustomComparers();
     customComparers.Find(null);
 }
 public void Register_and_unregister_ok()
 {
     var customComparers = new CustomComparers();
     customComparers.Register<Foo>((x, y) => x.Value.CompareTo(y.Value));
     customComparers.Unregister<Foo>();
     var comparer = customComparers.Find(typeof(Foo));
     Assert.IsNull(comparer);
 }
 public void Equals_ok(int foo1, int foo2, int expectedSign)
 {
     var customComparers = new CustomComparers();
     customComparers.Register<Foo>((x, y) => x.Value.CompareTo(y.Value));
     Comparison comparer = customComparers.Find(typeof(Foo));
     int actualSign = comparer(new Foo(foo1), new Foo(foo2));
     Assert.AreEqual(expectedSign, actualSign, (x, y) => Math.Sign(x) == Math.Sign(y));
 }