示例#1
0
 public void Init()
 {
     mockInventoryManager = new Mock <IInventoryManager>();
     mockAccountManager   = new Mock <IAccountManager>();
     mockCardManager      = new Mock <ICardManager>();
     vending = new Vending(mockInventoryManager.Object, mockAccountManager.Object, mockCardManager.Object);
 }
示例#2
0
    void Start()
    {
        //find the player and enter the player into our object...
        //so we don't have to manually place them in the inspector

        instace = this;
    }
示例#3
0
        public void ShowAll_Cond_Expect()   // ???
        {
            //Arrange
            Vending myVendor = new Vending();   // vending machine is now populated with standard products
            //Act

            //Assert
        }
示例#4
0
        public void Constructor_Create_NotEmpty()
        {
            //Arrange
            Vending myVendor = new Vending();   // vending machine is now populated with standard products
            //Act
            List <Product> collection = myVendor.GetProducts();

            //Assert
            Assert.NotEmpty(collection);
        }
示例#5
0
        public void GetId_CreateVendorPickDrinkOut_CheckedIdIs2()
        {
            //Arrange
            Vending        myVendor   = new Vending();
            List <Product> collection = myVendor.GetProducts();
            Product        myProduct  = collection[2];
            int            expectedId = 2;
            //Act
            int myProductId = myProduct.GetId();

            //Assert
            Assert.Equal(expectedId, myProductId);
        }
        public void Enough_Money()
        {
            //arrange
            double  userMoney = 1;
            bool    expected  = true;
            Vending test      = new Vending();

            //act
            bool actual = test.checkAndCharge(userMoney);

            // assert
            Assert.AreEqual(expected, actual, "It is not charging properly.");
        }
        public void Too_Little_Money()
        {
            // arrange
            double  userMoney = .5;
            bool    expected  = false;
            Vending test      = new Vending();

            // act
            bool actual = test.checkAndCharge(userMoney);

            // assert
            Assert.AreEqual(expected, actual, "It is not charging properly.");
        }
示例#8
0
        public void InsertMoney_PutInHundred_HundredInSaldo()
        {
            //Arrange
            Vending myVendor      = new Vending(); // vending machine is now populated with standard products
            int     expectedValue = 100;

            //Act
            myVendor.InsertMoney(MyLocalCurrency.Hundred);
            int userMoney = myVendor.Saldo();

            //Assert
            Assert.Equal(expectedValue, userMoney);
        }
示例#9
0
        public void EndTeansaction_PutInMoneyExit_ReturnsMoneyVendorEmpty()
        {
            //Arrange
            Vending myVendor      = new Vending(); // vending machine is now populated with standard products
            int     expectedSaldo = 0;

            //Act
            myVendor.InsertMoney((MyLocalCurrency)100); // Even if ve pretend to buy, we need money!
            myVendor.EndTeansaction();
            int userSaldo = myVendor.Saldo();

            //Assert
            Assert.Equal(expectedSaldo, userSaldo);
        }
示例#10
0
        public void EndTeansaction_PutInMoneyExit_SameAmountProductsLeftInVendor()
        {
            //Arrange
            Vending        myVendor              = new Vending(); // vending machine is now populated with standard products
            List <Product> collection            = myVendor.GetProducts();
            int            expectedNumberOfItems = 3;

            //Act
            myVendor.InsertMoney((MyLocalCurrency)100); // Even if ve pretend to buy, we need money!
            myVendor.EndTeansaction();
            int numberOfItems2 = collection.Count;

            //Assert
            Assert.Equal(expectedNumberOfItems, numberOfItems2);
        }
示例#11
0
        public void Constructor_Create_ThreeItems()
        {
            //Arrange
            Vending        myVendor           = new Vending(); // vending machine is now populated with standard products
            int            expectedSumOfItems = 3;
            int            numberOfItems      = 0;
            List <Product> collection         = myVendor.GetProducts();

            //Act
            foreach (var item in collection)
            {
                numberOfItems++;
            }
            //Assert
            Assert.Equal(expectedSumOfItems, numberOfItems);
        }
示例#12
0
        public void Purchase_PutIn3ItemsBuy1_LessItemsLeftOnlyTwoItemsLeft()  //???
        {
            //Arrange
            Vending        myVendor              = new Vending(); // vending machine is now populated with standard products
            List <Product> collection            = myVendor.GetProducts();
            int            expectedNumberOfItems = 2;

            //Act
            myVendor.InsertMoney((MyLocalCurrency)100); // Even if ve pretend to buy, we need money!
            int NumberOfItems1 = collection.Count;

            myVendor.Purchase(1);                       // Purchase the first item in Vendor
            int NumberOfItems2 = collection.Count;

            //Assert
            Assert.NotEqual(NumberOfItems1, NumberOfItems2);
            Assert.Equal(expectedNumberOfItems, NumberOfItems2);
        }
示例#13
0
 public void Setup(Vending data)
 {
     vending    = data;
     name.text  = Entity.Name(data.Result);
     price.text = $"{data.Num}個 ¥{data.Price}";
 }
示例#14
0
        public static IDictionary <string, List <IModifier> > ReadTriggerLex(string filename)
        {
            var lex = new Dictionary <string, List <IModifier> >();

            using (var reader = new StreamReader(filename))
                using (var csv = new CsvReader(reader))
                {
                    csv.Configuration.HasHeaderRecord = true;
                    //Triggerword	ModifierType	Lookahead	ModValue	Extra
                    csv.Read();
                    csv.Configuration.Delimiter = ",";
                    while (csv.Read())
                    {
                        var mods      = new List <IModifier>();
                        var tword     = Program.InternConcurrentSafe(csv.GetField(0).ToLower());
                        var lookahead = int.Parse(csv.GetField(2));
                        var modValue  = float.Parse(csv.GetField(3).Replace(".", ","));

                        IModifier modifier = null; // this could be waaaay prettier... Just wanted to try a switch case
                        switch (csv.GetField(1))
                        {
                        case "mult":
                            modifier = new Mult(modValue, lookahead);
                            break;

                        case "v":
                            var tokens = new List <Token>();
                            foreach (string s in csv.GetField(4).Split("|")) // couldn't a vending just take strings instead?... no reason to have a token
                            {
                                tokens.Add(new Token(s, 0));
                            }
                            modifier = new Vending(modValue, lookahead, tokens);
                            break;

                        case "neg":
                            modifier = new Mult(-1.0f, lookahead);
                            break;

                        case "repeating":
                            modifier = new Repeating(modValue, lookahead, tword, int.Parse(csv.GetField(4)));
                            break;

                        case "special":
                            modifier = new Special(modValue, lookahead);
                            break;

                        default:
                            FileWriter.WriteErrorLog("[TriggerLexicon] Couldn't match triggerword '" + tword + " -> is it unique in the lex?");
                            break;
                        }

                        if (!lex.ContainsKey(tword))
                        {
                            mods.Add(modifier);
                            if (!lex.TryAdd(tword, mods))
                            {
                                FileWriter.WriteErrorLog("[Lexicon] Couldn't add '" + tword + "' with mod " + modifier + " -> is it unique in the lex?");
                            }
                        }
                        else
                        {
                            lex.TryGetValue(tword, out mods);
                            mods.Add(modifier);
                            lex.Remove(tword);
                            lex.Add(tword, mods);
                        }
                    }
                    reader.Close();
                }
            return(lex);
        }
示例#15
0
 public void setVending(Vending vending)
 {
     this.vending = vending;
 }
示例#16
0
        static void Main(string[] args)
        {
            Vending myVending = new Vending();
            int     userInput;

            Console.WriteLine("Hello Vending Machine!");

            /*
             * //====== Tester av Enums och Dictionaries för eget bruk ==============
             * int EnFemtiLapp = (int)MyLocalCurrency.Fifty;
             * Console.WriteLine("{0} = {1}",(MyLocalCurrency)50, EnFemtiLapp);
             *
             * Dictionary<MyLocalCurrency, int> moneyCollection = new Dictionary<MyLocalCurrency, int>();
             *
             * moneyCollection.Add(MyLocalCurrency.Fifty, 2);
             * moneyCollection.Add(MyLocalCurrency.One, 2);
             * moneyCollection.Add(MyLocalCurrency.Twenty, 2);
             * Console.WriteLine("Antal Valörer: " + moneyCollection.Count);
             *
             * foreach (KeyValuePair<MyLocalCurrency, int> myValor in moneyCollection)
             * {
             *  System.Console.WriteLine($"{myValor.Key}: {myValor.Value}");
             * }
             *
             *
             * === Tester av klassen MoneyPool ===========
             * MoneyPool AnotherMoneyPool = new MoneyPool();
             * AnotherMoneyPool.Add(MyLocalCurrency.Hundred);
             * AnotherMoneyPool.Add(MyLocalCurrency.Ten);
             * AnotherMoneyPool.Add(MyLocalCurrency.Fifty);
             * AnotherMoneyPool.Add(MyLocalCurrency.Ten);
             * AnotherMoneyPool.Add(MyLocalCurrency.Five);
             * AnotherMoneyPool.Add(MyLocalCurrency.One);
             *
             * ========== More tests: ===========================================
             * for (int myLoop = 0; myLoop <= 1000; myLoop++)
             * {
             *  Console.Write("{0} ", Enum.GetName(typeof(MyLocalCurrency), myLoop));
             * }
             */
            bool Repeat = true;

            // ===== input some money:
            while (Repeat)
            {
                Console.Clear();
                Console.WriteLine("Vendor offers: ");
                myVending.ShowAll();
                Console.WriteLine("\nCurrency acceptance: 1,5,10,20,50,100,1000.");
                Console.WriteLine("User money saldo: [0=exit] " + myVending.Saldo());
                Console.Write("Insert Money: ");
                userInput = GetNumber();
                if (userInput == 0)
                {
                    Repeat = false;
                }

                if (Repeat)
                {
                    myVending.InsertMoney((Models.MyLocalCurrency)userInput);
                    Console.WriteLine("User money saldo: " + myVending.Saldo());
                }
            }

            //====== show goods: ========
            Console.Clear();
            Console.WriteLine("Vendorlist: ");
            myVending.ShowAll();

            Console.WriteLine("User money saldo: " + myVending.Saldo());
            Console.WriteLine("What you wanna buy? [id]: ");
            userInput = GetNumber();
            myVending.Purchase(userInput);
            Console.WriteLine("\n===== Checking rest of products in Vending Machine ==");
            myVending.ShowAll();
            Console.WriteLine("=====================================================\n");
            myVending.EndTeansaction();
            Console.WriteLine("Thanks for shopping att Buy n Large (BnL Corp.)!");
        }
示例#17
0
 public VendingTest()
 {
     _vending = new Vending();
     _vending.Reset();
 }