Exemple #1
0
        public void OnBuyItemFromVendorEventTest()
        {
            // Arrange
            BuyFromVendorResult <IItemInstance> boughtResult = null;
            int eventCount = 0;

            _vendor.OnBoughtFromVendor += (sender, result) =>
            {
                boughtResult = result;
                eventCount++;
            };

            _vendorCollection.Add(_product1, 10);
            _customerCurrencies.Add(_gold, 100);

            // Act
            var bought = _vendor.BuyFromVendor(_customer, _item1, 2);

            // Assert
            Assert.IsNull(bought.error);
            Assert.AreEqual(1, eventCount);

            Assert.AreEqual(boughtResult.amount, 2);
            Assert.AreEqual(boughtResult.item, _product1);
            Assert.AreEqual(boughtResult.currencies[0].currency, _gold);
        }