Example #1
0
        public void ComplementInt64NullableEnum(Int64Enum?value)
        {
            CSharpArgumentInfo x      = CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null);
            CallSiteBinder     binder =
                Binder.UnaryOperation(
                    CSharpBinderFlags.None, ExpressionType.OnesComplement,
                    GetType(), new[] { x });
            CallSite <Func <CallSite, Int64Enum?, object> > site = CallSite <Func <CallSite, Int64Enum?, object> > .Create(binder);

            Func <CallSite, Int64Enum?, object> targ = site.Target;
            object result = targ(site, value);

            Assert.Equal(~value, result);
        }
Example #2
0
        public void EnumSubtraction(Int64Enum?x, Int64Enum?y, long expected, bool overflows)
        {
            dynamic d      = x;
            object  result = unchecked (d - y);

            Assert.Equal(expected, result);
            Assert.IsType <long>(result);
            if (overflows)
            {
                Assert.Throws <OverflowException>(() => checked (d - y));
            }
            else
            {
                result = checked (d - y);
                Assert.Equal(expected, result);
                Assert.IsType <long>(result);
            }
        }
Example #3
0
        public void LiftedEnumSubtraction(Int64Enum?enumVal, long?integralVal, Int64Enum?enMinusIn, Int64Enum?inMinusEn)
        {
            dynamic d      = enumVal;
            object  result = unchecked (d - integralVal);

            Assert.Equal(enMinusIn, result);
            Assert.IsType <Int64Enum>(result);
            result = unchecked (integralVal - d);
            Assert.Equal(inMinusEn, result);
            Assert.IsType <Int64Enum>(result);
            d      = integralVal;
            result = unchecked (enumVal - d);
            Assert.Equal(enMinusIn, result);
            Assert.IsType <Int64Enum>(result);
            result = unchecked (d - enumVal);
            Assert.Equal(inMinusEn, result);
            Assert.IsType <Int64Enum>(result);
        }
Example #4
0
        public void LiftedEnumAddition(Int64Enum?enumVal, long?integralVal, Int64Enum expected)
        {
            dynamic d      = enumVal;
            object  result = unchecked (d + integralVal);

            Assert.Equal(expected, result);
            Assert.IsType <Int64Enum>(result);
            result = unchecked (integralVal + d);
            Assert.Equal(expected, result);
            Assert.IsType <Int64Enum>(result);
            d      = integralVal;
            result = unchecked (enumVal + d);
            Assert.Equal(expected, result);
            Assert.IsType <Int64Enum>(result);
            result = unchecked (d + enumVal);
            Assert.Equal(expected, result);
            Assert.IsType <Int64Enum>(result);
        }
Example #5
0
        public void MultiValueTypeWithEnumAndNullTest()
        {
            int?      a = 0;
            long?     b = 1;
            string    c = "2";
            DateTime  d = DateTime.Now;
            Exception e = new ArgumentNullException();
            object    f = null;
            Int16Enum g = Int16Enum.A;
            Int32Enum?h = null;
            Int64Enum?i = Int64Enum.C;

            var types = Types.Of(new object[] { a, b, c, d, e, f, g, h, i }).ToList();

            types.Count.ShouldBe(9);
            types[0].ShouldBe(typeof(int));
            types[1].ShouldBe(typeof(long));
            types[2].ShouldBe(typeof(string));
            types[3].ShouldBe(typeof(DateTime));
            types[4].ShouldBe(typeof(ArgumentNullException));
            types[5].ShouldBeNull();
            types[6].ShouldBe(typeof(Int16Enum));
            types[7].ShouldBeNull();
            types[8].ShouldBe(typeof(Int64Enum));

            types = Types.Of(new object[] { a, b, c, d, e, f, g, h, i }, TypeOfOptions.Underlying).ToList();

            types.Count.ShouldBe(9);
            types[0].ShouldBe(typeof(int));
            types[1].ShouldBe(typeof(long));
            types[2].ShouldBe(typeof(string));
            types[3].ShouldBe(typeof(DateTime));
            types[4].ShouldBe(typeof(ArgumentNullException));
            types[5].ShouldBeNull();
            types[6].ShouldBe(typeof(Int16Enum));
            types[7].ShouldBeNull();
            types[8].ShouldBe(typeof(Int64Enum));
        }
Example #6
0
        Populate(
            int stringSize,
            int binarySize)
        {
            PartitionKey = typeof(AllDataExplicit).Name;
            RowKey       = Guid.NewGuid().ToString();

            // Fields + Nullable. 8 + 8 + 6 = 22
            StringField     = DataGenerator.GetStringSizeFixed(stringSize);
            StringFieldNull = null;

            BoolField        = DataGenerator.Rnd.Next(2) == 1;
            BoolFieldNull    = null;
            BoolFieldNullNot = DataGenerator.Rnd.Next(2) == 1;

            IntField        = DataGenerator.Rnd.Next(Int32.MaxValue);
            IntFieldNull    = null;
            IntFieldNullNot = DataGenerator.Rnd.Next(int.MaxValue);

            Int64Field        = (Int64)(DataGenerator.Rnd.Next(Int32.MaxValue) * DataGenerator.Rnd.Next(Int32.MaxValue));
            Int64FieldNull    = null;
            Int64FieldNullNot = (Int64)(DataGenerator.Rnd.Next(Int32.MaxValue) * DataGenerator.Rnd.Next(Int32.MaxValue));

            DoubleField        = DataGenerator.Rnd.NextDouble() * Double.MaxValue;
            DoubleFieldNull    = null;
            DoubleFieldNullNot = DataGenerator.Rnd.NextDouble() * Double.MaxValue;

            DateTimeField        = DateTime.UtcNow;
            DateTimeFieldNull    = null;
            DateTimeFieldNullNot = DateTime.UtcNow;

            GuidField        = Guid.NewGuid();
            GuidFieldNull    = null;
            GuidFieldNullNot = Guid.NewGuid();

            BinaryField     = DataGenerator.GetBytesSizeFixed(binarySize);
            BinaryFieldNull = null;

            // intrinsic morphs + Nullable. 7 * 4 = 28
            ByteFieldMin     = Byte.MinValue;
            ByteFieldMax     = Byte.MaxValue;
            ByteFieldNull    = null;
            ByteFieldNullNot = (byte)DataGenerator.Rnd.Next(byte.MaxValue);

            SByteFieldMin     = SByte.MinValue;
            SByteFieldMax     = SByte.MaxValue;
            SByteFieldNull    = null;
            SByteFieldNullNot = (sbyte)DataGenerator.Rnd.Next(sbyte.MaxValue);

            Int16FieldMin     = Int16.MinValue;
            Int16FieldMax     = Int16.MaxValue;
            Int16FieldNull    = null;
            Int16FieldNullNot = (Int16)DataGenerator.Rnd.Next(Int16.MaxValue);

            UInt16FieldMin     = UInt16.MinValue;
            UInt16FieldMax     = UInt16.MaxValue;
            UInt16FieldNull    = null;
            UInt16FieldNullNot = (UInt16)DataGenerator.Rnd.Next(UInt16.MaxValue);

            UInt32FieldMin     = UInt32.MinValue;
            UInt32FieldMax     = UInt32.MaxValue;
            UInt32FieldNull    = null;
            UInt32FieldNullNot = (UInt32)DataGenerator.Rnd.Next(UInt16.MaxValue);

            UInt64FieldMin     = UInt64.MinValue;
            UInt64FieldMax     = UInt64.MaxValue;
            UInt64FieldNull    = null;
            UInt64FieldNullNot = (UInt64)(DataGenerator.Rnd.Next(Int32.MaxValue) * DataGenerator.Rnd.Next(Int32.MaxValue));

            CharFieldMin     = Char.MinValue;
            CharFieldMax     = Char.MaxValue;
            CharFieldNull    = null;
            CharFieldNullNot = (Char)DataGenerator.Rnd.Next(Char.MaxValue);

            // Enums - 8
            ByteEnumField        = ByteEnum.Value2;
            ByteEnumFieldNull    = null;
            ByteEnumFieldNullNot = ByteEnum.Value1;

            SByteEnumField        = SByteEnum.Value2;
            SByteEnumFieldNull    = null;
            SByteEnumFieldNullNot = SByteEnum.Value1;

            Int16EnumField        = Int16Enum.Value2;
            Int16EnumFieldNull    = null;
            Int16EnumFieldNullNot = Int16Enum.Value1;

            UInt16EnumField        = UInt16Enum.Value2;
            UInt16EnumFieldNull    = null;
            UInt16EnumFieldNullNot = UInt16Enum.Value1;

            Int32EnumField        = Int32Enum.Value2;
            Int32EnumFieldNull    = null;
            Int32EnumFieldNullNot = Int32Enum.Value1;

            UInt32EnumField        = UInt32Enum.Value2;
            UInt32EnumFieldNull    = null;
            UInt32EnumFieldNullNot = UInt32Enum.Value1;

            Int64EnumField        = Int64Enum.Value2;
            Int64EnumFieldNull    = null;
            Int64EnumFieldNullNot = Int64Enum.Value1;

            UInt64EnumField        = UInt64Enum.Value2;
            UInt64EnumFieldNull    = null;
            UInt64EnumFieldNullNot = UInt64Enum.Value1;

            // Object
            // Create a derived generic object type to validate correct de-serialization
            var employeeInfo = EmployeeInfo <int> .CreateNew();

            employeeInfo.Dummy = 101;

            PersonInfo = employeeInfo;
        }