public void TestDecimalRangeOptionParsingFromConstructor(string rawText, string expectedDecimalRangeStartAsStr, string expectedDecimalRangeEndAsStr, bool isFromInclusive, bool isToInclusive) { decimal start = decimal.Parse(expectedDecimalRangeStartAsStr); decimal end = decimal.Parse(expectedDecimalRangeEndAsStr); Range <decimal> expected = new Range <decimal>(start, end, isFromInclusive, isToInclusive); DecimalRangeCommandOption option = new DecimalRangeCommandOption(CommandOptionKind.Date, rawText); Assert.Equal(expected, option.GetValue(null)); }
public void TestDecimalRangeOptionParsing() { decimal from = 12.34m; decimal to = 67.89m; Range <decimal> range = new Range <decimal>(from, to); DecimalRangeCommandOption option = new DecimalRangeCommandOption(CommandOptionKind.Date); Range <decimal> parsedData; bool successful = option.TryParseData("[12.34, 67.89]", out parsedData); Assert.True(successful); Assert.Equal(range, parsedData); successful = option.SetData("asdf"); Assert.False(successful); Assert.False(option.IsDataValid); successful = option.SetData("44.44"); Assert.True(successful); Assert.True(option.IsDataValid); }