public void TryParseLongThatOverFlowsShouldBeFalse() { long?result; Assert.True(EdmValueParser.TryParseLong("9223372036854775807", out result)); Assert.Equal(long.MaxValue, result); Assert.False(EdmValueParser.TryParseLong("9223372036854775808", out result)); Assert.Null(result); }
public void TryParseLongThatOverFlowsShouldBeFalse() { long?result; EdmValueParser.TryParseLong("9223372036854775807", out result).Should().BeTrue(); result.Should().Be(long.MaxValue); EdmValueParser.TryParseLong("9223372036854775808", out result).Should().BeFalse(); result.Should().NotHaveValue(); }
private IEnumerable <EdmError> ComputeErrors() { Int64?value; if (!EdmValueParser.TryParseLong(this.expression.Value, out value)) { return(new EdmError[] { new EdmError(this.Location, EdmErrorCode.InvalidInteger, Strings.ValueParser_InvalidInteger(this.expression.Value)) }); } else { return(Enumerable.Empty <EdmError>()); } }
private long ComputeValue() { long?nullable; if (EdmValueParser.TryParseLong(this.expression.Value, out nullable)) { return(nullable.Value); } else { return((long)0); } }
private IEnumerable <EdmError> ComputeErrors() { long?nullable; if (EdmValueParser.TryParseLong(this.expression.Value, out nullable)) { return(Enumerable.Empty <EdmError>()); } else { EdmError[] edmError = new EdmError[1]; edmError[0] = new EdmError(base.Location, EdmErrorCode.InvalidInteger, Strings.ValueParser_InvalidInteger(this.expression.Value)); return(edmError); } }
protected long?OptionalLong(string attributeName) { XmlAttributeInfo attr = GetOptionalAttribute(this.currentElement, attributeName); if (!attr.IsMissing) { long?value; if (!EdmValueParser.TryParseLong(attr.Value, out value)) { this.ReportError(this.currentElement.Location, EdmErrorCode.InvalidLong, Edm.Strings.ValueParser_InvalidLong(attr.Value)); } return(value); } return(null); }
protected long?OptionalLong(string attributeName) { long? nullable; XmlAttributeInfo optionalAttribute = this.GetOptionalAttribute(this.currentElement, attributeName); if (optionalAttribute.IsMissing) { long?nullable1 = null; return(nullable1); } else { if (!EdmValueParser.TryParseLong(optionalAttribute.Value, out nullable)) { base.ReportError(this.currentElement.Location, EdmErrorCode.InvalidLong, Strings.ValueParser_InvalidLong(optionalAttribute.Value)); } return(nullable); } }
private Int64 ComputeValue() { Int64?value; return(EdmValueParser.TryParseLong(this.expression.Value, out value) ? value.Value : 0); }