/// <summary>
        /// This method define inputed command
        /// </summary>
        public ICommand DefineCommand(string commandName)
        {
            ICommand command;

            if (commandName == "add car")
            {
                command = new AddCarFromConsoleCommand(this.Receiver, ConsoleInteractions.CreateCar());
            }
            else if (commandName.IndexOf("remove car") == 0)
            {
                command = SetRemoveCarCommand(commandName);
            }
            else if (commandName == "count types")
            {
                command = new CountTypesCommand(this.Receiver);
            }
            else if (commandName == "count all")
            {
                command = new CountAllCommand(this.Receiver);
            }
            else if (commandName == "average price")
            {
                command = new AveragePriceCommand(this.Receiver);
            }
            else if (commandName.IndexOf("average price type") == 0)
            {
                command = SetAveragePriceTypeCommand(commandName);
            }
            else
            {
                throw new ArgumentException("Unknown command");
            }

            return(command);
        }
Esempio n. 2
0
        public void TestCountTypesCommand()
        {
            Product      firstProduct  = new Product("Biscuits", "Tuc", 1, 2);
            Product      secondProduct = new Product("Biscuits", "Oreo", 3, 3);
            Product      thirdProduct  = new Product("Chocolate", "Red riding hood", 5, 2.5);
            GoodsStorage storage       = new GoodsStorage();

            storage.StoreTheProduct(firstProduct);
            storage.StoreTheProduct(secondProduct);
            storage.StoreTheProduct(thirdProduct);
            ICommand typesCounter = new CountTypesCommand(storage.listOfProducts);

            Assert.AreEqual(typesCounter.Count(), 2);
        }