public Receive ( |
||
inCash | ||
inMoney | Money | |
inCount | int | |
리턴 | bool |
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)); }
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])); } }
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); } }
public void _利用者がお金を投入する() { var role = new CoinMeckRole (); var received = new CashDeal(); Assert.True(role.Receive(received, Money.Coin10)); Assert.True(role.Receive(received, Money.Coin50)); Assert.True(role.Receive(received, Money.Coin100)); Assert.True(role.Receive(received, Money.Coin500)); Assert.True(role.Receive(received, Money.Bill1000)); Assert.False(role.Receive(received, Money.Coin1)); Assert.False(role.Receive(received, Money.Coin5)); Assert.False(role.Receive(received, Money.Bill2000)); Assert.False(role.Receive(received, Money.Bill5000)); Assert.False(role.Receive(received, Money.Bill10000)); Assert.True(role.Receive(received, Money.Coin10)); Assert.True(role.Receive(received, Money.Coin50)); Assert.True(role.Receive(received, Money.Coin100)); Assert.True(role.Receive(received, Money.Coin500)); Assert.True(role.Receive(received, Money.Bill1000)); Assert.False(role.Receive(received, Money.Coin1)); Assert.False(role.Receive(received, Money.Coin5)); Assert.False(role.Receive(received, Money.Bill2000)); Assert.False(role.Receive(received, Money.Bill5000)); Assert.False(role.Receive(received, Money.Bill10000)); Assert.False(received.RecevedMoney.Contains(Money.Coin1)); Assert.False(received.RecevedMoney.Contains(Money.Coin5)); Assert.False(received.RecevedMoney.Contains(Money.Bill2000)); Assert.False(received.RecevedMoney.Contains(Money.Bill5000)); Assert.False(received.RecevedMoney.Contains(Money.Bill10000)); Assert.That(received.ChangedAount, Is.EqualTo(3320)); }
public void _何も購入せずお金を排出する(Money inMoney, int inRepeat) { var role = new CoinMeckRole (); var received = new CashDeal(); var pool = TestHelper.InitInfinityReservedChange(); for (var i = 0; i < inRepeat; ++i) { role.Receive(received, inMoney); } var changed = role.Eject(received, pool) .GroupBy(m => m) .ToDictionary(g => g.Key, g => g) ; Assert.That(received.RecevedMoney.Count, Is.EqualTo(0)); Assert.That(changed.Count, Is.EqualTo(1)); Assert.True(changed.ContainsKey(inMoney)); Assert.That(changed[inMoney].Count(), Is.EqualTo(inRepeat)); }
public void _何も購入せずお金を排出する(Money inMoney, int inRepeat) { var role = new CoinMeckRole (); var received = new CashDeal(); var pool = TestHelper.InitInfinityReservedChange(); role.Receive(received, inMoney, inRepeat); var expectReceived = received.RecevedMoney.TotalAmount(); var changes = role.Eject(received, pool).Credits .Where(c => c.Value > 0) .ToDictionary(g => g.Key, g => g.Value) ; Assert.That(received.RecevedMoney.TotalAmount(), Is.EqualTo(expectReceived)); Assert.That(changes.Count, Is.EqualTo(1)); Assert.True(changes.ContainsKey(inMoney)); Assert.That(changes[inMoney], Is.EqualTo(inRepeat)); }
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)); } }
public void _商品購入後お金を排出する( [ValueSource(typeof(_商品購入後お金を排出するParams), "Source")] _商品購入後お金を排出するParams.Parameter inParameter) { var role = new CoinMeckRole(); var received = new CashDeal(); var pool = TestHelper.InitInfinityReservedChange(); foreach (var m in inParameter.ReceivedMoney) { for (var i = 0; i < m.Item2; ++i) { role.Receive (received, m.Item1); } } Assert.True(role.Purchase(received, 100)); var changed = role.Eject(received, pool) .GroupBy(m => m) .ToDictionary(g => g.Key, g => g) ; var lookup = inParameter.ChangedMoney.ToDictionary(m => m.Item1, m => m.Item2); Assert.That(received.RecevedMoney.Count, Is.EqualTo(0)); Assert.That(received.UsedAmount, Is.EqualTo(100)); Assert.That(changed.Count, Is.EqualTo(lookup.Count), "count money type (id = {0})", inParameter.Id); foreach (var pair in changed) { Assert.True(lookup.ContainsKey(pair.Key), "money ({0}) should be contained (id = {1})", pair.Key, inParameter.Id); Assert.That(pair.Value.Count(), Is.EqualTo (lookup[pair.Key]), "money ({0}) count should be equaled (id = {1})", pair.Key, inParameter.Id); } }
public void _商品購入後お金を排出する( [ValueSource(typeof(_商品購入後お金を排出するParams), "Source")] _商品購入後お金を排出するParams.Parameter inParameter) { var role = new CoinMeckRole(); var received = new CashDeal(); var pool = TestHelper.InitInfinityReservedChange(); foreach (var m in inParameter.ReceivedMoney) { for (var i = 0; i < m.Item2; ++i) { role.Receive (received, m.Item1, 1); } } var newReceives = new CashDeal(role.CalcChanges(received, pool, 100)); var changes = role.Eject(newReceives, pool) .Credits .Where(c => c.Value > 0) .ToDictionary(g => g.Key, g => g.Value) ; var lookup = inParameter.ChangedMoney.ToDictionary(m => m.Item1, m => m.Item2); Assert.That(changes.Count, Is.EqualTo(lookup.Count), "count money type (id = {0})", inParameter.Id); foreach (var pair in changes) { Assert.True(lookup.ContainsKey(pair.Key), "money ({0}) should be contained (id = {1})", pair.Key, inParameter.Id); Assert.That(pair.Value, Is.EqualTo (lookup[pair.Key]), "money ({0}) count should be equaled (id = {1})", pair.Key, inParameter.Id); } }
public void _利用者がお金を投入する_正しくない投入枚数の場合(int inCount) { var role = new CoinMeckRole (); var received = new CashDeal(); Assert.False(role.Receive(received, Money.Coin10, inCount)); Assert.False(role.Receive(received, Money.Coin50, inCount)); Assert.False(role.Receive(received, Money.Coin100, inCount)); Assert.False(role.Receive(received, Money.Coin500, inCount)); Assert.False(role.Receive(received, Money.Bill1000, inCount)); Assert.False(role.Receive(received, Money.Coin1, inCount)); Assert.False(role.Receive(received, Money.Coin5, inCount)); Assert.False(role.Receive(received, Money.Bill2000, inCount)); Assert.False(role.Receive(received, Money.Bill5000, inCount)); Assert.False(role.Receive(received, Money.Bill10000, inCount)); Assert.False(role.Receive(received, Money.Coin10, inCount)); Assert.False(role.Receive(received, Money.Coin50, inCount)); Assert.False(role.Receive(received, Money.Coin100, inCount)); Assert.False(role.Receive(received, Money.Coin500, inCount)); Assert.False(role.Receive(received, Money.Bill1000, inCount)); Assert.False(role.Receive(received, Money.Coin1, inCount)); Assert.False(role.Receive(received, Money.Coin5, inCount)); Assert.False(role.Receive(received, Money.Bill2000, inCount)); Assert.False(role.Receive(received, Money.Bill5000, inCount)); Assert.False(role.Receive(received, Money.Bill10000, inCount)); Assert.False(received.RecevedMoney.Credits.ContainsKey(Money.Coin1)); Assert.False(received.RecevedMoney.Credits.ContainsKey(Money.Coin5)); Assert.False(received.RecevedMoney.Credits.ContainsKey(Money.Bill2000)); Assert.False(received.RecevedMoney.Credits.ContainsKey(Money.Bill5000)); Assert.False(received.RecevedMoney.Credits.ContainsKey(Money.Bill10000)); Assert.That(received.ChangedAount, Is.EqualTo(0)); }