Esempio n. 1
0
        public void VerifyNextTrainerPurchaseSpendsResources(int i_numTrainers, int i_expectedCostForNextTrainer)
        {
            Dictionary <string, int> trainers = new Dictionary <string, int>();

            trainers.Add(TrainerManager.NORMAL_TRAINERS, i_numTrainers);
            mTrainerData = new TrainerManager(new ViewModel(), CreateTrainerSaveData_WithCounts(trainers), new Dictionary <string, UnitProgress>());

            int             costForNextTrainer = mTrainerData.GetNextTrainerCost();
            NormalInventory realInventory      = new NormalInventory();

            realInventory.SetResource(VirtualCurrencies.GOLD, costForNextTrainer);

            mTrainerData.InitiateTrainerPurchase(realInventory);

            Assert.AreEqual(realInventory.GetResourceCount(VirtualCurrencies.GOLD), 0);
        }
        public void VerifyUpgradeSpendDeduction(int i_level)
        {
            mUpgrade.Value = i_level;

            NormalInventory inventory = new NormalInventory();

            foreach (KeyValuePair <string, int> cost in mUpgrade.ResourcesToUpgrade)
            {
                int amount = (int)Math.Ceiling(cost.Value * Math.Pow(mUpgrade.UpgradeData.Coefficient, mUpgrade.Value));
                inventory.SetResource(cost.Key, amount);
            }

            if (mUpgrade.CanUpgrade(inventory))
            {
                mUpgrade.InitiateUpgradeWithResources(inventory);

                foreach (KeyValuePair <string, int> cost in mUpgrade.ResourcesToUpgrade)
                {
                    string resource        = cost.Key;
                    int    remainingAmount = inventory.GetResourceCount(resource);
                    Assert.AreEqual(0, remainingAmount);
                }
            }
        }