Beispiel #1
0
        public override void Execute()
        {
            var apartment = new Residence
            {
                new Bathroom(),
                new Bedroom(),
                new Kitchen()
            };

            var apartmentMaid = new Maid();

            Assert.Equal(0, apartmentMaid.ServiceCost);

            apartment.Accept(apartmentMaid);
            Assert.Equal(Maid.BathroomPrice + Maid.BedroomPrice, apartmentMaid.ServiceCost);

            var apartmentPlumber = new Plumber();

            Assert.Equal(Plumber.BasePrice, apartmentPlumber.ServiceCost);

            apartment.Accept(apartmentPlumber);
            Assert.Equal(Plumber.BasePrice + Plumber.BathroomPrice + Plumber.KitchenPrice, apartmentPlumber.ServiceCost);


            var house = new Residence
            {
                new Bathroom(),
                new Bathroom(),

                new Bedroom(),
                new Bedroom(),
                new Bedroom(),

                new Kitchen(),
                new LivingRoom()
            };

            var houseMaid = new Maid();

            house.Accept(houseMaid);
            Assert.Equal(Maid.BathroomPrice * 2 + Maid.BedroomPrice * 3, houseMaid.ServiceCost);

            var housePlumber = new Plumber();

            house.Accept(housePlumber);
            Assert.Equal(Plumber.BasePrice + Plumber.BathroomPrice * 2 + Plumber.KitchenPrice, housePlumber.ServiceCost);
        }