public void CarPriceComparerCompareDoesNotSortCarsIfEqualPrice() { Car car1 = new Car() { Price = 0M }; Car car2 = new Car() { Price = 0M }; CarPriceComparer comparer = new CarPriceComparer(); Assert.IsTrue(comparer.Compare(car1, car2) == 0); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Car> _car1 = test.CreateVariable <Car>(); TestVariable <Car> _car2 = test.CreateVariable <Car>(); TestVariable <CarPriceComparer> _comparer = test.CreateVariable <CarPriceComparer>(); test.Arrange(_car1, Expr(() => new Car() { Price = 0M })); test.Arrange(_car2, Expr(() => new Car() { Price = 0M })); test.Arrange(_comparer, Expr(() => new CarPriceComparer())); test.Assert.IsTrue(Expr(_comparer, _car1, _car2, (c1, c2, c3) => c1.Compare(c2, c3) == 0)); test.Execute(); }
public void CarPriceComparerCompareSortsNullFirst() { Car car = new Car(); CarPriceComparer comparer = new CarPriceComparer(); Assert.IsTrue(comparer.Compare(car, null) > 0); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Car> _car = test.CreateVariable <Car>(); TestVariable <CarPriceComparer> _comparer = test.CreateVariable <CarPriceComparer>(); test.Arrange(_car, Expr(() => new Car())); test.Arrange(_comparer, Expr(() => new CarPriceComparer())); test.Assert.IsTrue(Expr(_comparer, _car, (c1, c2) => c1.Compare(c2, null) > 0)); test.Execute(); }