示例#1
0
        public void Economy_RemoveCurrencyNotExisting()
        {
            var       name     = MUtils.GetRandomString();
            ICurrency currency = new MCurrency(name);

            Assert.Throws <InvalidOperationException>(() => MEconomy.Instance.RemoveCurrency(currency));
        }
示例#2
0
        public void Currency_TrySpendReturnsFalse()
        {
            var       name     = MUtils.GetRandomString();
            ICurrency currency = new MCurrency(name);

            Assert.That(currency.TrySpend(1000) == false);
        }
示例#3
0
        public void Currency_AddNegative()
        {
            var       name     = MUtils.GetRandomString();
            ICurrency currency = new MCurrency(name);

            Assert.Throws <ArgumentException>(() => currency.Add(-1000));
            Assert.That(currency.Value == 0);
        }
示例#4
0
        public void AddingEventCategory_Multiple()
        {
            var name = MUtils.GetRandomString();

            MEvents.Instance.AddEventsCategory(name);
            MEvents.Instance.AddEventsCategory(name);

            LogAssert.Expect(LogType.Log, $"Events category [{name}] already exists!");
        }
示例#5
0
        public void Currency_TrySpendResultsInZero()
        {
            var       name     = MUtils.GetRandomString();
            ICurrency currency = new MCurrency(name);

            currency.TrySpend(1000);

            Assert.That(currency.Value == 0);
        }
示例#6
0
        public void Economy_AddCurrency()
        {
            var       name     = MUtils.GetRandomString();
            ICurrency currency = new MCurrency(name);

            MEconomy.Instance.AddCurrency(currency);

            Assert.That(MEconomy.Instance[name].Name.Equals(name));
        }
示例#7
0
        public void Economy_AddCurrencyAlreadyExistingNonIdentical()
        {
            var       name      = MUtils.GetRandomString();
            ICurrency currency  = new MCurrency(name);
            ICurrency currency2 = new MCurrency(name);

            MEconomy.Instance.AddCurrency(currency);
            Assert.Throws <InvalidOperationException>(() => MEconomy.Instance.AddCurrency(currency2));
        }
示例#8
0
        public void Currency_AddValueCorrect()
        {
            var       name     = MUtils.GetRandomString();
            ICurrency currency = new MCurrency(name);

            currency.Add(1000);

            Assert.That(currency.Value == 1000);
        }
示例#9
0
        public void CurrencyEvent_CurrencyAdded()
        {
            var       name     = MUtils.GetRandomString();
            ICurrency currency = new MCurrency(name);

            MEvents.Add(new MEvents.EventDelegate <CurrencyAddedEvent>(e => Debug.Log(e.Currency.Name)));

            currency.Add(5);

            LogAssert.Expect(LogType.Log, name);
        }
示例#10
0
        public void CurrencyEvent_UpgradableCurrencyUpgraded()
        {
            var name     = MUtils.GetRandomString();
            var capacity = new CappedCurrencyCapacity(5, 10);
            IUpgradableCurrency currency = new MCappedCurrency(name, capacity);

            MEvents.Add(new MEvents.EventDelegate <UpgradableCurrencyUpgradeSuccessEvent>((e => { Debug.Log(e.Currency.Name); })));

            currency.TryUpgradeCapacity();

            LogAssert.Expect(LogType.Log, name);
        }
示例#11
0
        public void CurrencyEvent_CurrencyInsufficient()
        {
            var       name     = MUtils.GetRandomString();
            ICurrency currency = new MCurrency(name);

            MEvents.Add(new MEvents.EventDelegate <CurrencyInsufficientEvent>((e => { Debug.Log(e.AmountAttempted); })));

            currency.Add(5);
            currency.TrySpend(7);

            LogAssert.Expect(LogType.Log, "7");
        }
示例#12
0
        public void AddingEventListener()
        {
            var category = MUtils.GetRandomString();

            MEvents.Instance.AddEventsCategory(category);

            MEvents.Instance[category].Raise(new TestEvent(0));
            LogAssert.NoUnexpectedReceived();
            MEvents.Instance[category].Add <TestEvent>(TestEventListener);
            MEvents.Instance[category].Raise(new TestEvent(0));

            LogAssert.Expect(LogType.Log, "TestEvent0");
            LogAssert.NoUnexpectedReceived();
        }
示例#13
0
        public void Economy_RemoveCurrency()
        {
            var       name     = MUtils.GetRandomString();
            ICurrency currency = new MCurrency(name);

            MEconomy.Instance.AddCurrency(currency);

            MEconomy.Instance.RemoveCurrency(currency);

            Assert.Throws <KeyNotFoundException>(() =>
            {
                var curr = MEconomy.Instance[name];
            });
        }