public void ClrTypeMappingPrimitiveTypeOverflowTest() { var edmModel = this.GetParserResult(ClrTypeMappingTestModelBuilder.PrimitiveTypeOverflowTest()); var annotations = edmModel.FindVocabularyAnnotations(edmModel.FindType("NS1.Person")); Func <string, IEdmIntegerConstantExpression> GetIntegerExpression = (termName) => { var valueAnnotation = annotations.Single(n => n.Term.Name == termName) as IEdmValueAnnotation; return((IEdmIntegerConstantExpression)valueAnnotation.Value); }; Func <string, IEdmFloatingConstantExpression> GetFloatExpression = (termName) => { var valueAnnotation = annotations.Single(n => n.Term.Name == termName) as IEdmValueAnnotation; return((IEdmFloatingConstantExpression)valueAnnotation.Value); }; Func <string, IEdmValue> GetEdmValue = (termName) => { var valueAnnotation = annotations.Single(n => n.Term.Name == termName) as IEdmValueAnnotation; var edmToClrEvaluator = new EdmToClrEvaluator(null); return(edmToClrEvaluator.Evaluate(valueAnnotation.Value)); }; var edmToClrConverter = new EdmToClrConverter(); Assert.AreEqual(edmToClrConverter.AsClrValue(GetFloatExpression("SingleValue"), typeof(Single)), float.PositiveInfinity, "It should return Infinit for Single when the value is greater than Single.MaxValue."); Assert.AreEqual(edmToClrConverter.AsClrValue(GetFloatExpression("NegativeSingleValue"), typeof(Single)), float.NegativeInfinity, "It should return Negative Infinit for Single when the value is less than Single.MinValue."); this.VerifyThrowsException(typeof(OverflowException), () => edmToClrConverter.AsClrValue(GetEdmValue("ByteValue"), typeof(byte))); this.VerifyThrowsException(typeof(OverflowException), () => edmToClrConverter.AsClrValue <byte>(GetEdmValue("ByteValue"))); this.VerifyThrowsException(typeof(OverflowException), () => new EdmToClrEvaluator(null).EvaluateToClrValue <byte>(GetIntegerExpression("ByteValue"))); this.VerifyThrowsException(typeof(OverflowException), () => edmToClrConverter.AsClrValue(GetEdmValue("SByteValue"), typeof(sbyte))); this.VerifyThrowsException(typeof(OverflowException), () => edmToClrConverter.AsClrValue <sbyte>(GetEdmValue("SByteValue"))); this.VerifyThrowsException(typeof(OverflowException), () => new EdmToClrEvaluator(null).EvaluateToClrValue <sbyte>(GetIntegerExpression("SByteValue"))); }