public void ConvertFrom_Boolean_ReturnsBool() { var value = new Boolean(true); var result = ValueTypeConverter.ConvertFrom <bool>(value); Assert.True(result); }
private IExpression Atom() { IExpression atom; switch (lookAhead.Type) { case ExpressionTokenType.Identifier: return(Identifier()); case ExpressionTokenType.LeftParen: NextToken(); atom = Expression(); if (lookAhead.Type != ExpressionTokenType.RightParen) { throw UnexpectedTokenException("Expected ')'."); } atom = new ParenthesisExpression(atom); break; case ExpressionTokenType.Text: var text = lookAhead.Sequence.Substring(1, lookAhead.Sequence.Length - 2); atom = new Text(text); break; case ExpressionTokenType.Integer: var integer = long.Parse(lookAhead.Sequence, CultureInfo.InvariantCulture); atom = new Integer(integer); break; case ExpressionTokenType.Decimal: var number = double.Parse(lookAhead.Sequence, CultureInfo.InvariantCulture); atom = new Number(number); break; case ExpressionTokenType.True: case ExpressionTokenType.False: var boolean = lookAhead.Sequence.ToLowerInvariant() == "true"; atom = new Boolean(boolean); break; case ExpressionTokenType.RegexPattern: var pattern = lookAhead.Sequence.Substring(1, lookAhead.Sequence.Length - 2); atom = new RegExp(pattern); break; default: throw UnexpectedTokenException(); } NextToken(); return(atom); }