public CoinsPort GetPortCoin(CoinValueEnum coinValue) { var result = new CoinsPort(); switch (coinValue) { case CoinValueEnum.One: result = OneRurPort; break; case CoinValueEnum.Two: result = TwoRurPort; break; case CoinValueEnum.Five: result = FiveRurPort; break; case CoinValueEnum.Ten: result = TenRurPort; break; } if (result.CoinValue != coinValue) { throw new Exception("Данный тип монет не поддерживается."); } return(result); }
public static bool PayOut(this CoinsPort port, CoinModel coin) { bool resultOk = (port.Count > 0 && (port.CoinType == coin.CoinType && port.CoinValue == coin.Value)); if (resultOk) { port.Count--; } return(resultOk); }
public static void PayoutCoinsFailed2Test() { const int coinsCount = 2; var port = new CoinsPort() { CoinType = CoinTypeEnum.Ruble, CoinValue = CoinValueEnum.Two, Count = coinsCount }; var oneRuble = new CoinModel { CoinType = CoinTypeEnum.Ruble, Value = CoinValueEnum.One }; bool isSuccress = port.PayOut(oneRuble); Assert.IsFalse(isSuccress); Assert.AreEqual(port.Count, coinsCount); }
public BugModel() { OneRurPort = new CoinsPort() { CoinValue = CoinValueEnum.One }; TwoRurPort = new CoinsPort() { CoinValue = CoinValueEnum.Two }; FiveRurPort = new CoinsPort() { CoinValue = CoinValueEnum.Five }; TenRurPort = new CoinsPort() { CoinValue = CoinValueEnum.Ten }; }