public void Economy_RemoveCurrencyNotExisting() { var name = MUtils.GetRandomString(); ICurrency currency = new MCurrency(name); Assert.Throws <InvalidOperationException>(() => MEconomy.Instance.RemoveCurrency(currency)); }
public void Currency_TrySpendReturnsFalse() { var name = MUtils.GetRandomString(); ICurrency currency = new MCurrency(name); Assert.That(currency.TrySpend(1000) == false); }
public void Currency_AddNegative() { var name = MUtils.GetRandomString(); ICurrency currency = new MCurrency(name); Assert.Throws <ArgumentException>(() => currency.Add(-1000)); Assert.That(currency.Value == 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!"); }
public void Currency_TrySpendResultsInZero() { var name = MUtils.GetRandomString(); ICurrency currency = new MCurrency(name); currency.TrySpend(1000); Assert.That(currency.Value == 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)); }
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)); }
public void Currency_AddValueCorrect() { var name = MUtils.GetRandomString(); ICurrency currency = new MCurrency(name); currency.Add(1000); Assert.That(currency.Value == 1000); }
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); }
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); }
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"); }
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(); }
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]; }); }