상속: IUserPurchaseRole
예제 #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, 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));
        }
예제 #3
0
        public PurchaseContext(ChangePool inChanges, ItemRackPosition inItems)
        {
            mDealAmount = new CashDeal();
            mChanges    = inChanges;
            mItems      = inItems;

            mCoinMeckRole = new CoinMeckRole();
            mItemRole     = new ItemRackRole();
        }
예제 #4
0
        public PurchaseContext(ChangePool inChanges, ItemRackPosition inItems)
        {
            mDealAmount = new CashDeal();
            mChanges = inChanges;
            mItems = inItems;

            mCoinMeckRole = new CoinMeckRole();
            mItemRole = new ItemRackRole();
        }
예제 #5
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));            }
        }
예제 #6
0
        public void _指定された位置の商品ラックを検索する_未配置の位置を指定する場合()
        {
            var positions = TestHelper.InitInfinityItems(ItemRackState.CanNotPurchase);

            var itemRackRole = new  ItemRackRole();
            var rack = itemRackRole.FindRackAt(positions, 3);
            Assert.That(rack, Is.Null);
        }
예제 #7
0
        public void _指定された位置の商品ラックを検索する()
        {
            var racks = TestHelper.InitInfinityItems(ItemRackState.CanNotPurchase);

            var itemRackRole = new  ItemRackRole();
            var rack = itemRackRole.FindRackAt(racks, 0);
            Assert.That(rack, Is.Not.Null);
            Assert.That(rack.Item.Name, Is.EqualTo("Item0"));
        }