public void _価値から金種への変換(int inValue, Money inType, MoneyStatus inStatus) { var money = MoneyResolver.Resolve(inValue); Assert.That(money.Type, Is.EqualTo(inType)); Assert.That(money.Status, Is.EqualTo(inStatus)); }
public void _金種からお金への解決(Money inType, MoneyStatus inStatus, int inValue) { var money = MoneyResolver.Resolve(inType); Assert.That(money.Type, Is.EqualTo(inType)); Assert.That(money.Status, Is.EqualTo(inStatus)); Assert.That(money.Value, Is.EqualTo(inValue)); }
public CommandParserRepository() { mParsers = new Dictionary <string, Func <string[], IParseResult> > { { "ins", (tokens) => { var it = tokens.Skip(1).GetEnumerator(); var status = ParseResultStatus.InvalidMoney; var money = Money.Unknown; var count = 1; if (it.MoveNext()) { int v; if (!int.TryParse(it.Current, out v)) { return(new ParseErrorResult(ParseResultStatus.InvalidMoney)); } var m = MoneyResolver.Resolve(v); if (m.Status != MoneyStatus.Available) { return(new ParseErrorResult(ParseResultStatus.InvalidMoney)); } status = ParseResultStatus.Success; money = m.Type; } if (it.MoveNext()) { if (!int.TryParse(it.Current, out count)) { return(new ParseErrorResult(ParseResultStatus.InvalidMoney)); } if (count <= 0 || count > 100) { return(new ParseErrorResult(ParseResultStatus.InvalidMoney)); } } return(new MoneyInsertionParseResult { Status = status, Money = money, Count = count, }); } }, { "eject", (token) => { return(new MoneyEjectParseResult { Status = ParseResultStatus.Success, }); } }, { "show", (tokens) => { var it = tokens.Skip(1).GetEnumerator(); if (it.MoveNext()) { var subCommand = it.Current; switch (subCommand) { case "amount": return(new ShowAmountParseResult { Status = ParseResultStatus.Success, }); case "item": return(new ShowItemParseResult { Status = ParseResultStatus.Success, }); } } return(new ParseErrorResult(ParseResultStatus.NotSupportedCommand)); } }, { "help", (tokens) => { var it = tokens.Skip(1).GetEnumerator(); var result = new HelpParseResult { Status = ParseResultStatus.Success }; if (it.MoveNext()) { result.Command = it.Current; } return(result); } }, }; }