Purchase() public method

public Purchase ( ItemRack inRack ) : ItemInfo
inRack ItemRack
return ItemInfo
Exemplo n.º 1
0
        public Item Purchase(int inPosition)
        {
            var rack = mItemRole.FindRackAt(mItems, inPosition);

            if (rack == null)
            {
                // error
            }

            if (!mItemRole.CanItemPurchase(rack))
            {
                // error
            }

            mCoinMeckRole.Purchase(mDealAmount, rack.Item.Price);

            return(mItemRole.Purchase(rack));
        }
Exemplo n.º 2
0
        public void _商品を購入する()
        {
            var racks = TestHelper.InitInfinityItems(ItemRackState.CanNotPurchase);

            var pool = TestHelper.InitInfinityReservedChange();
            var credit = new CashDeal();

            var coinMeckRole = new CoinMeckRole();
            var itemRackRole = new  ItemRackRole();

            coinMeckRole.Receive(credit, Money.Coin100, 1);
            coinMeckRole.Receive(credit, Money.Coin10, 1);
            coinMeckRole.Receive(credit, Money.Coin10, 1);

            var rack = itemRackRole.FindRackAt(racks, 0);
            itemRackRole.UpdateItemSelectionState(
                rack, credit,
                coinMeckRole.CalcChanges(credit, pool, rack.Item.Price)
            );

            var svCount = rack.Count;
            Assert.That(rack.State, Is.EqualTo(ItemRackState.CanPurchase));

            coinMeckRole.CalcChanges(credit, pool, rack.Item.Price);
            var item = itemRackRole.Purchase(rack);

            Assert.That(item, Is.Not.Null);
            Assert.That(item.Name, Is.EqualTo("Item0"));

            Assert.That(rack.Count, Is.EqualTo(svCount-1));
        }