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 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 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)); }
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 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 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)); }