private void NotEqualLink() { Patterns.AbstractFactory.AbstractFactory meatWolfFactory = new MeatWolfFactory() .SetMeatAnimal(new Sheep(null)) .SetMeatWeight(0) .SetWolfName(null); Assert.False(meatWolfFactory.BuildFood() == meatWolfFactory.BuildFood()); Assert.False(meatWolfFactory.BuildCanEat() == meatWolfFactory.BuildCanEat()); Patterns.AbstractFactory.AbstractFactory gasVehicleFactory = new GasVehicleFactory() .SetGasBrand(null) .SetGasWeight(0) .SetVehicleBrand(null) .SetVehicleConsumption(0.0) .SetVehicleModel(null); Assert.False(gasVehicleFactory.BuildCanEat() == gasVehicleFactory.BuildCanEat()); Assert.False(gasVehicleFactory.BuildFood() == gasVehicleFactory.BuildFood()); }
public void Expected() { Patterns.AbstractFactory.AbstractFactory meatWolfFactory = new MeatWolfFactory() .SetMeatAnimal(new Sheep("John")) .SetMeatWeight(1.5) .SetWolfName("Jim"); Assert.Equal(0, meatWolfFactory.UniqId); ICanEat wolf = meatWolfFactory.BuildCanEat(); Assert.Equal("Wolf Jim", wolf.Name); IFood sheepMeat = meatWolfFactory.BuildFood(); Assert.Equal("Wolf Jim", wolf.Name); Assert.Equal(1.5, sheepMeat.Weight); Assert.Equal("Sheep John meat", sheepMeat.Name); wolf.Eat(sheepMeat); Assert.Equal(0, sheepMeat.Weight); Patterns.AbstractFactory.AbstractFactory gasVehicleFactory = new GasVehicleFactory() .SetGasBrand("Bas") .SetGasWeight(1000) .SetVehicleBrand("GrrMotor") .SetVehicleConsumption(20) .SetVehicleModel("o0O"); Assert.Equal(1, gasVehicleFactory.UniqId); ICanEat vehicle = gasVehicleFactory.BuildCanEat(); Assert.Equal("Vehicle «o0O», GrrMotorⓒ", vehicle.Name); IFood gas = gasVehicleFactory.BuildFood(); Assert.Equal("Vehicle «o0O», GrrMotorⓒ", vehicle.Name); Assert.Equal("Gas «Bas»", gas.Name); Assert.Equal(1000.0, gas.Weight); vehicle.Eat(gas); Assert.Equal(980.0, gas.Weight); NotEqualLink(); }