UpdateItemSelectionState() public method

public UpdateItemSelectionState ( ItemRack inRack, CashDeal inCredits, CreditPool inChangesPool ) : ItemRackState
inRack ItemRack
inCredits CashDeal
inChangesPool CreditPool
return ItemRackState
示例#1
0
        public void _お金投入による商品選択状態の変化_売り切れの場合(
            [ValueSource(typeof(商品選択状態の変化Params), "SoldOutSource")] 
            商品選択状態の変化Params.Param inParameter)
        {
            var positions = TestHelper.InitInfinityItems(ItemRackState.Soldout);

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

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

            foreach (var c in inParameter.Credits) {
                coinMeckRole.Receive(credit, c, 1);
            }

            foreach (var p in Enumerable.Range(0, positions.Racks.Length)) {
                var newState = itemRackRole.UpdateItemSelectionState(
                    positions.Racks[p], credit,
                    coinMeckRole.CalcChanges(credit, pool, positions.Racks[p].Item.Price)
                    );

                Assert.That(newState, Is.EqualTo(inParameter.States[p]));
            }
        }
示例#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);
            coinMeckRole.Receive(credit, Money.Coin10);
            coinMeckRole.Receive(credit, Money.Coin10);

            var rack = itemRackRole.FindRackAt(racks, 0);
            itemRackRole.UpdateItemSelectionState(rack, credit, pool);

            var svCount = rack.Count;
            Assert.That(itemRackRole.CanItemPurchase(rack), Is.True);

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

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

            Assert.That(credit.UsedAmount, Is.EqualTo(120));
            Assert.That(credit.ChangedAount, Is.EqualTo(0));

            Assert.That(rack.Count, Is.EqualTo(svCount-1));
        }
示例#3
0
        public void ReceiveMoney(Money inMoney)
        {
            mCoinMeckRole.Receive(mDealAmount, inMoney);

            foreach (var rack in mItems.Items.Where(r => r.State == ItemRackState.CanNotPurchase))
            {
                mItemRole.UpdateItemSelectionState(rack, mDealAmount, mChanges);
            }
        }
示例#4
0
        public void _お金投入による商品選択状態の変化(
            [ValueSource(typeof(商品選択状態の変化Params), "Source")] 
            商品選択状態の変化Params.Param inParameter)
        {
            var racks = TestHelper.InitInfinityItems(ItemRackState.CanNotPurchase);

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

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

            foreach (var c in inParameter.Credits) {
                coinMeckRole.Receive(credit, c);
            }

            foreach (var result in racks.Items.Zip(inParameter.States, (r, s) => Tuple.Create(r, s))) {
                itemRackRole.UpdateItemSelectionState(result.Item1, credit, pool);

                Assert.That(result.Item1.State, Is.EqualTo(result.Item2));
                Assert.That(itemRackRole.CanItemPurchase(result.Item1), Is.EqualTo(result.Item2 == ItemRackState.CanPurchase));            }
        }