public void NotOnNumericTypeIsNotSupported() { IEdmTypeReference type = EdmCoreModel.Instance.GetInt32(false); var result = TypePromotionUtils.PromoteOperandType(UnaryOperatorKind.Not, ref type); result.Should().BeFalse(); }
public void NotOnComplexTypeIsNotSupported() { IEdmTypeReference type = HardCodedTestModel.GetPersonAddressProp().Type; var result = TypePromotionUtils.PromoteOperandType(UnaryOperatorKind.Not, ref type); result.Should().BeFalse(); }
public void NegateOnTimeOfDayIsNotSupported() { IEdmTypeReference type = EdmCoreModel.Instance.GetTemporal(EdmPrimitiveTypeKind.TimeOfDay, false); var result = TypePromotionUtils.PromoteOperandType(UnaryOperatorKind.Negate, ref type); result.Should().BeFalse(); }
public void NegateOnNullIsSupported() { IEdmTypeReference type = null; var result = TypePromotionUtils.PromoteOperandType(UnaryOperatorKind.Negate, ref type); result.Should().BeTrue(); type.Should().BeNull(); }
public void NegateOnNumericTypeIsSupported() { IEdmTypeReference type = EdmCoreModel.Instance.GetInt32(false); var result = TypePromotionUtils.PromoteOperandType(UnaryOperatorKind.Negate, ref type); result.Should().BeTrue(); type.ShouldBeEquivalentTo(EdmCoreModel.Instance.GetInt32(false)); }
/// <summary> /// Get the promoted type reference of the operand /// </summary> /// <param name="operand">the operand</param> /// <param name="unaryOperatorKind">the operator kind</param> /// <returns>the type reference of the operand</returns> private static IEdmTypeReference PromoteOperandType(SingleValueNode operand, UnaryOperatorKind unaryOperatorKind) { IEdmTypeReference typeReference = operand.TypeReference; if (!TypePromotionUtils.PromoteOperandType(unaryOperatorKind, ref typeReference)) { string typeName = operand.TypeReference == null ? "<null>" : operand.TypeReference.ODataFullName(); throw new ODataException(ODataErrorStrings.MetadataBinder_IncompatibleOperandError(typeName, unaryOperatorKind)); } return(typeReference); }