public ListAccountCommand(string rawText, RepositoryBag repositories) : base(rawText, repositories) { IdOption = new IntegerCommandOption(CommandOptionKind.Id); CategoryIdOption = new IntegerCommandOption(CommandOptionKind.Category); DescriptionOption = new StringCommandOption(CommandOptionKind.Description); NameOption = new StringCommandOption(CommandOptionKind.Name); PriorityOption = new IntegerRangeCommandOption(CommandOptionKind.Priority); FundsOption = new MoneyRangeCommandOption(CommandOptionKind.FundsExpr); AccountTypeOption = new EnumCommandOption <AccountKind>(CommandOptionKind.AccountType); }
public AddAccountCommand(string rawText, RepositoryBag repositories, string accountName) : base(rawText, repositories) { AccountId = new IntegerCommandOption(CommandOptionKind.Account); AccountName = new StringCommandOption(CommandOptionKind.Name); CategoryNameOption = new StringCommandOption(CommandOptionKind.Category); DescriptionOption = new StringCommandOption(CommandOptionKind.Description); FundsOption = new MoneyCommandOption(CommandOptionKind.Funds); PriorityOption = new IntegerCommandOption(CommandOptionKind.Priority); AccountTypeOption = new EnumCommandOption <AccountKind>(CommandOptionKind.AccountType); AccountName.SetData(accountName); }
public void TestEnumOptionParsing() { FakeEnum value1 = FakeEnum.SecondItem; EnumCommandOption <FakeEnum> option = new EnumCommandOption <FakeEnum>(CommandOptionKind.Date); FakeEnum parsedData; bool successful = option.TryParseData("SecondItem", out parsedData); Assert.True(successful); Assert.Equal(value1, parsedData); successful = option.SetData("asdf"); Assert.False(successful); Assert.False(option.IsDataValid); successful = option.SetData("ThirdItem"); Assert.True(successful); Assert.True(option.IsDataValid); }
public void TestEnumOptionParsingFromConstructor(string rawText, FakeEnum expected) { EnumCommandOption <FakeEnum> option = new EnumCommandOption <FakeEnum>(CommandOptionKind.Date, rawText); Assert.Equal(expected, option.GetValue(null)); }