Пример #1
0
        public void NotOnNumericTypeIsNotSupported()
        {
            IEdmTypeReference type = EdmCoreModel.Instance.GetInt32(false);
            var result             = TypePromotionUtils.PromoteOperandType(UnaryOperatorKind.Not, ref type);

            result.Should().BeFalse();
        }
Пример #2
0
        public void NotOnComplexTypeIsNotSupported()
        {
            IEdmTypeReference type = HardCodedTestModel.GetPersonAddressProp().Type;
            var result             = TypePromotionUtils.PromoteOperandType(UnaryOperatorKind.Not, ref type);

            result.Should().BeFalse();
        }
Пример #3
0
        public void NegateOnTimeOfDayIsNotSupported()
        {
            IEdmTypeReference type = EdmCoreModel.Instance.GetTemporal(EdmPrimitiveTypeKind.TimeOfDay, false);
            var result             = TypePromotionUtils.PromoteOperandType(UnaryOperatorKind.Negate, ref type);

            result.Should().BeFalse();
        }
Пример #4
0
        public void NegateOnNullIsSupported()
        {
            IEdmTypeReference type = null;
            var result             = TypePromotionUtils.PromoteOperandType(UnaryOperatorKind.Negate, ref type);

            result.Should().BeTrue();
            type.Should().BeNull();
        }
Пример #5
0
        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));
        }
Пример #6
0
        /// <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);
        }