public void TestCleanup()
 {
     _inventory = null;
     _item      = null;
     _billingMachineOperations = null;
     _sodaMachine = null;
 }
        public void TestInit()
        {
            var availableItems = new Dictionary <int, IItem>();

            //Initialize the test inventory
            availableItems = new Dictionary <int, IItem>
            {
                { 1, new Beverage()
                  {
                      Code = 1, Name = "Coke", Rate = 5, Quantity = 100
                  } },
                { 2, new Beverage()
                  {
                      Code = 2, Name = "Fanta", Rate = 5, Quantity = 500
                  } },
                { 3, new Beverage()
                  {
                      Code = 3, Name = "Sprite", Rate = 5, Quantity = 600
                  } }
            };
            _inventory = Substitute.For <IInventory>();
            _inventory.AvailableItems.ReturnsForAnyArgs(availableItems);
            _item = new Beverage()
            {
                Code = 1, Name = "Fanta", Rate = 5, Quantity = 1
            };
            _billingMachineOperations = new BillingMachineOperations(_inventory, _item);
            _sodaMachine = new SodaMachine(_billingMachineOperations, _item);
            _billingMachineOperations.ClearBalance();
        }
Пример #3
0
 public AddMoneyState(ISodaMachine sodaMachine)
 {
     this._sodaMachine = sodaMachine;
 }
Пример #4
0
 public SelectSodaState(ISodaMachine sodaMachine)
 {
     this._sodaMachine = sodaMachine;
 }
Пример #5
0
 public ReleaseSodaState(ISodaMachine sodaMachine)
 {
     this._sodaMachine = sodaMachine;
 }
Пример #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to the Soda Machine!");
            Console.WriteLine("Would you like Coca Cola sodas or Pepsi Sodas?");
            Console.WriteLine("If you want Coca Cola sodas then press 1");
            Console.WriteLine("If you want Pepsi sodas then press 2");
            ConsoleKeyInfo machineChoice = Console.ReadKey();

            Console.WriteLine(Environment.NewLine);
            ISodaMachine sodaMachine = null;
            ISoda        brand       = null;
            string       sodaName    = String.Empty;

            switch (machineChoice.Key)
            {
            case ConsoleKey.NumPad1:
                sodaMachine = new CocaColaMachine();
                brand       = sodaMachine.LoadSelection();
                DisplaySelection(typeof(CocaColaSelection));
                sodaName = GetSodaChoice(typeof(CocaColaSelection));
                break;

            case ConsoleKey.D1:
                sodaMachine = new CocaColaMachine();
                brand       = sodaMachine.LoadSelection();
                DisplaySelection(typeof(CocaColaSelection));
                sodaName = GetSodaChoice(typeof(CocaColaSelection));
                break;

            case ConsoleKey.NumPad2:
                sodaMachine = new PepsiMachine();
                brand       = sodaMachine.LoadSelection();
                DisplaySelection(typeof(PepsiSelection));
                sodaName = GetSodaChoice(typeof(PepsiSelection));
                break;

            case ConsoleKey.D2:
                sodaMachine = new PepsiMachine();
                brand       = sodaMachine.LoadSelection();
                DisplaySelection(typeof(PepsiSelection));
                sodaName = GetSodaChoice(typeof(PepsiSelection));
                break;

            default:
                Console.WriteLine("No Choice Selected.");
                Console.WriteLine("Closing Program.");
                Environment.Exit(0);
                break;
            }

            Console.WriteLine(Environment.NewLine);
            if (!String.IsNullOrWhiteSpace(sodaName))
            {
                brand.Dispense(sodaName);
            }
            else
            {
                Console.WriteLine("Invalid soda choosen");
            }
            Console.WriteLine("Press any key to exit program.");
            Console.ReadKey();
            Environment.Exit(0);
        }