コード例 #1
0
        public void GetSumType_ExpandFalse()
        {
            Type GetSumType <T>() => RemoteGroupExpressionCompiler.GetSumType(typeof(T), false);

            // Validation: check lambda type in new T[0].Sum(i => i)

            Assert.Equal(typeof(int), GetSumType <sbyte>());
            Assert.Equal(typeof(int), GetSumType <byte>());

            Assert.Equal(typeof(int), GetSumType <short>());
            Assert.Equal(typeof(int), GetSumType <ushort>());

            Assert.Equal(typeof(int), GetSumType <int>());
            Assert.Equal(typeof(long), GetSumType <uint>());

            Assert.Equal(typeof(long), GetSumType <long>());
            Assert.Equal(typeof(decimal), GetSumType <ulong>());

            Assert.Equal(typeof(float), GetSumType <float>());
            Assert.Equal(typeof(double), GetSumType <double>());
            Assert.Equal(typeof(decimal), GetSumType <decimal>());
        }
コード例 #2
0
        public void GetSumType_ExpandTrue()
        {
            Type GetSumType <T>() => RemoteGroupExpressionCompiler.GetSumType(typeof(T), true);

            // Don't convert integer types to decimal because SQL decimals have variable precision
            // Except for UInt64 for which there is no better choice

            Assert.Equal(typeof(long), GetSumType <sbyte>());
            Assert.Equal(typeof(long), GetSumType <byte>());

            Assert.Equal(typeof(long), GetSumType <short>());
            Assert.Equal(typeof(long), GetSumType <ushort>());

            Assert.Equal(typeof(long), GetSumType <int>());
            Assert.Equal(typeof(long), GetSumType <uint>());

            Assert.Equal(typeof(long), GetSumType <long>());
            Assert.Equal(typeof(decimal), GetSumType <ulong>());

            Assert.Equal(typeof(double), GetSumType <float>());
            Assert.Equal(typeof(double), GetSumType <double>());
            Assert.Equal(typeof(decimal), GetSumType <decimal>());
        }