public void CarMakeModelPriceComparerCompareSortsAccordingToCarPrice() { Car car1 = new Car() { Price = 0M }; Car car2 = new Car() { Price = 1M }; CarMakeModelPriceComparer comparer = new CarMakeModelPriceComparer(); 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 <CarMakeModelPriceComparer> _comparer = test.CreateVariable <CarMakeModelPriceComparer>(); test.Arrange(_car1, Expr(() => new Car() { Price = 0M })); test.Arrange(_car2, Expr(() => new Car() { Price = 1M })); test.Arrange(_comparer, Expr(() => new CarMakeModelPriceComparer())); test.Assert.IsTrue(Expr(_comparer, _car1, _car2, (c1, c2, c3) => c1.Compare(c2, c3) < 0)); test.Execute(); }
public void CarMakeModelPriceComparerCompareSortsNullFirst() { Car car = new Car(); CarMakeModelPriceComparer comparer = new CarMakeModelPriceComparer(); Assert.IsTrue(comparer.Compare(car, null) > 0); // TestTools Code UnitTest test = Factory.CreateTest(); TestVariable <Car> _car = test.CreateVariable <Car>(); TestVariable <CarMakeModelPriceComparer> _comparer = test.CreateVariable <CarMakeModelPriceComparer>(); test.Arrange(_car, Expr(() => new Car())); test.Arrange(_comparer, Expr(() => new CarMakeModelPriceComparer())); test.Assert.IsTrue(Expr(_comparer, _car, (c1, c2) => c1.Compare(c2, null) > 0)); test.Execute(); }
public void CarMakeModelPriceComparerCompareDoesNotSortIfEverythingIsEqual() { Car car1 = new Car(); Car car2 = new Car(); CarMakeModelPriceComparer comparer = new CarMakeModelPriceComparer(); 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 <CarMakeModelPriceComparer> _comparer = test.CreateVariable <CarMakeModelPriceComparer>(); test.Arrange(_car1, Expr(() => new Car())); test.Arrange(_car2, Expr(() => new Car())); test.Arrange(_comparer, Expr(() => new CarMakeModelPriceComparer())); test.Assert.IsTrue(Expr(_comparer, _car1, _car2, (c1, c2, c3) => c1.Compare(c2, c3) == 0)); test.Execute(); }