예제 #1
0
        public ElectricKettle GetCheapestAPlusElectricKettle()
        {
            var cheapestElectricKettle = new ElectricKettle();

            foreach (var electricKettle in ElectricKettles)
            {
                if (electricKettle.EnergyClass == "A+")
                {
                    cheapestElectricKettle = electricKettle;
                    break;
                }
            }

            if (cheapestElectricKettle.Price == 0)
            {
                return(null);
            }

            foreach (var electricKettle in ElectricKettles)
            {
                if (electricKettle.EnergyClass == "A+" && electricKettle.Price < cheapestElectricKettle.Price)
                {
                    cheapestElectricKettle = electricKettle;
                }
            }

            return(cheapestElectricKettle);
        }
예제 #2
0
        static void Main(string[] args)
        {
            var liquids = new List <ILiquid>()
            {
                new Liquid("Water"), new Liquid("Fuel")
            };
            var liquidProvider = new LiquidProvider(liquids);

            var energies = new List <IEnergy>()
            {
                new Energy("Electricity"), new Energy("SomethingElse")
            };
            var energyProvider = new EnergyProvider(energies);

            var regularKettle  = new RegularKettle();
            var electricKettle = new ElectricKettle();

            var capacity = new CapacityUnit(100);
            var utensil  = new Utensil("Kettle", capacity);
            var boiler   = new Boiler("Кипятильник");

            regularKettle.Utensil = utensil;
            regularKettle.Boiler  = boiler;
            regularKettle.WorksOn = energies;

            electricKettle.Utensil = utensil;
            electricKettle.Boiler  = boiler;
            electricKettle.WorksOn = energies;

            var regularKettleRunner  = new Runner.Runner(liquidProvider, energyProvider, regularKettle);
            var electricKettleRunner = new Runner.Runner(liquidProvider, energyProvider, electricKettle);
        }
예제 #3
0
        public void ElectricKettle_Should_Return_Starting()
        {
            ElectricKettle kettle = ElectricKettle.GetSingleton();

            var data = kettle.GetState();

            Assert.AreEqual("Starting", data.Item1);
            Assert.AreEqual(ElectricKettleStatus.Empty, data.Item2);
        }
 public bool Equals(ElectricKettle other)
 {
     return(Manufacturer == other.Manufacturer &&
            Model == other.Model &&
            EnergyClass == other.EnergyClass &&
            Color == other.Color &&
            Price == other.Price &&
            Power == other.Power &&
            Capacity == other.Capacity);
 }
예제 #5
0
        public void ElectricKettle_Should_Return_Filling()
        {
            ElectricKettle kettle = ElectricKettle.GetSingleton();

            kettle.Fill();
            var data = kettle.GetState();

            Assert.AreEqual("Filling...", data.Item1);
            Assert.AreEqual(ElectricKettleStatus.InProgress, data.Item2);
        }
예제 #6
0
        public void ElectricKettle_Should_Return_BoilingThenBoiledStatus()
        {
            ElectricKettle kettle = ElectricKettle.GetSingleton();

            kettle.Fill();
            kettle.Boil();
            var data = kettle.GetState();

            Assert.AreEqual("Boiling...", data.Item1);
            Assert.AreEqual(ElectricKettleStatus.Boiled, data.Item2);
        }
예제 #7
0
        public void ElectricKettle_Should_Return_DrainingThenEmptyStatus()
        {
            ElectricKettle kettle = ElectricKettle.GetSingleton();

            kettle.Fill();
            kettle.Boil();
            kettle.Drain();
            var data = kettle.GetState();

            Assert.AreEqual("Draining...", data.Item1);
            Assert.AreEqual(ElectricKettleStatus.Empty, data.Item2);
        }
예제 #8
0
        public void ElectricKettle_Should_Be_Singleton()
        {
            ElectricKettle firstVariable  = ElectricKettle.GetSingleton();
            ElectricKettle secondVariable = ElectricKettle.GetSingleton();


            firstVariable.Fill();
            var data   = firstVariable.GetState();
            var result = secondVariable.GetState();

            Assert.AreEqual(data.Item1, result.Item1);
            Assert.AreEqual(data.Item2, result.Item2);
        }
예제 #9
0
 public bool HasElectricKettle(ElectricKettle electricKettle)
 {
     return(ElectricKettles.Contains(electricKettle));
 }