Ejemplo n.º 1
0
 public void TestRoundtripByteEnum([ValueSource(nameof(ByteEnumValues))] ByteEnum value)
 {
     Roundtrip(value).Should().Be(value);
     Roundtrip(new GenericType <ByteEnum> {
         Value = value
     }).Value.Should().Be(value);
 }
Ejemplo n.º 2
0
        public void SerializeDeserializeByteEnumUtf16(ByteEnum input)
        {
            var serialized   = JsonSerializer.Generic.Utf16.Serialize(input);
            var deserialized = JsonSerializer.Generic.Utf16.Deserialize <ByteEnum>(serialized);

            Assert.Equal(input, deserialized);
        }
Ejemplo n.º 3
0
    public void ByteSize(ByteEnum @enum)
    {
        Value value = Value.Create(@enum);

        Assert.True(value.TryGetValue(out ByteEnum result));
        Assert.Equal(@enum, result);
        Assert.True(value.TryGetValue(out ByteEnum? nullResult));
        Assert.Equal(@enum, nullResult !.Value);
        value = Value.Create((ByteEnum?)@enum);
        Assert.True(value.TryGetValue(out result));
        Assert.Equal(@enum, result);
        Assert.True(value.TryGetValue(out nullResult));
        Assert.Equal(@enum, nullResult !.Value);

        // Create boxed
        value = new(@enum);
        Assert.True(value.TryGetValue(out result));
        Assert.Equal(@enum, result);
        Assert.True(value.TryGetValue(out nullResult));
        Assert.Equal(@enum, nullResult !.Value);
        value = new((ByteEnum?)@enum);
        Assert.True(value.TryGetValue(out result));
        Assert.Equal(@enum, result);
        Assert.True(value.TryGetValue(out nullResult));
        Assert.Equal(@enum, nullResult !.Value);
    }
Ejemplo n.º 4
0
        public void SerializeDeserializeIntegerByteEnumUtf8(ByteEnum input)
        {
            var serialized   = JsonSerializer.Generic.Utf8.Serialize <ByteEnum, ExcludeNullCamelCaseIntegerEnumResolver <byte> >(input);
            var deserialized = JsonSerializer.Generic.Utf8.Deserialize <ByteEnum, ExcludeNullCamelCaseIntegerEnumResolver <byte> >(serialized);

            Assert.Equal(input, deserialized);
        }
Ejemplo n.º 5
0
        public void ReadByteEnum(ByteEnum enumValue)
        {
            var intEnumContext = new MsgPackContext(convertEnumsAsStrings: false);
            var bytes          = MsgPackSerializer.Serialize((byte)enumValue, intEnumContext);
            var enumResult     = MsgPackSerializer.Deserialize <ByteEnum>(bytes, intEnumContext);

            enumResult.ShouldBe(enumValue);
        }
Ejemplo n.º 6
0
        public void WriteByteEnum(ByteEnum enumValue)
        {
            var intEnumContext = new MsgPackContext(convertEnumsAsStrings: false);
            var enumResult     = MsgPackSerializer.Serialize(enumValue, intEnumContext);
            var valueResult    = MsgPackSerializer.Serialize((byte)enumValue, intEnumContext);

            enumResult.ShouldBe(valueResult);
        }
Ejemplo n.º 7
0
        public void TestByteEnum()
        {
            ByteEnum data = ByteEnum.Second;

            var deserializeObject = TestBase <ByteEnum>(data);

            Assert.AreEqual(data, deserializeObject);
        }
Ejemplo n.º 8
0
    public static void Main()
    {
        ByteEnum b = ByteEnum.One;

        switch (b)
        {
        case ByteEnum.One: return;

        case ByteEnum.One | ByteEnum.Two: return;
        }
    }
Ejemplo n.º 9
0
 public void EnumByValue()
 {
     {
         IntEnum ret = NativeExportsNE.IntEnum.Subtract_Return(IntEnum.Max, IntEnum.Zero);
         Assert.Equal(IntEnum.Max, ret);
     }
     {
         ByteEnum ret = NativeExportsNE.ByteEnum.Subtract_Return(ByteEnum.Max, ByteEnum.Zero);
         Assert.Equal(ByteEnum.Max, ret);
     }
 }
Ejemplo n.º 10
0
    public static void TestToObject()
    {
        TestToObjectVerifySuccess <SByteEnum, sbyte>(42);
        TestToObjectVerifySuccess <SByteEnum, SByteEnum>((SByteEnum)0x42);
        TestToObjectVerifySuccess <UInt64Enum, ulong>(0x0123456789abcdefL);

        ulong    l = 0x0ccccccccccccc2aL;
        ByteEnum e = (ByteEnum)(Enum.ToObject(typeof(ByteEnum), l));

        Assert.True((sbyte)e == 0x2a);
    }
Ejemplo n.º 11
0
        public void SetFlagTest_ByteEnum()
        {
            ByteEnum flags = default;

            // Set each flag and clear
            for (int i = 0; i < sizeof(ByteEnum) * 8; i++)
            {
                ByteEnum newFlag = (ByteEnum)(1 << i);
                flags.SetFlags(newFlag);
                flags.Should().Be(newFlag);
                flags.ClearFlags(newFlag);
                flags.Should().Be(0);
            }
        }
Ejemplo n.º 12
0
        public void LiftedEnumAddition(ByteEnum?enumVal, byte?integralVal, ByteEnum expected)
        {
            dynamic d      = enumVal;
            object  result = unchecked (d + integralVal);

            Assert.Equal(expected, result);
            Assert.IsType <ByteEnum>(result);
            result = unchecked (integralVal + d);
            Assert.Equal(expected, result);
            Assert.IsType <ByteEnum>(result);
            d      = integralVal;
            result = unchecked (enumVal + d);
            Assert.Equal(expected, result);
            Assert.IsType <ByteEnum>(result);
            result = unchecked (d + enumVal);
            Assert.Equal(expected, result);
            Assert.IsType <ByteEnum>(result);
        }
Ejemplo n.º 13
0
        public void EnumByRef()
        {
            {
                IntEnum a        = IntEnum.Three;
                IntEnum b        = IntEnum.Two;
                IntEnum expected = IntEnum.One;

                IntEnum ret;
                NativeExportsNE.IntEnum.Subtract_Out(a, b, out ret);
                Assert.Equal(expected, ret);

                IntEnum refValue = b;
                NativeExportsNE.IntEnum.Subtract_In(a, in refValue);
                Assert.Equal(expected, refValue); // Value is updated even when passed with in keyword (matches built-in system)

                refValue = b;
                NativeExportsNE.IntEnum.Subtract_Ref(a, ref refValue);
                Assert.Equal(expected, refValue);
            }

            {
                ByteEnum a        = ByteEnum.Three;
                ByteEnum b        = ByteEnum.Two;
                ByteEnum expected = ByteEnum.One;

                ByteEnum ret;
                NativeExportsNE.ByteEnum.Subtract_Out(a, b, out ret);
                Assert.Equal(expected, ret);

                ByteEnum refValue = b;
                NativeExportsNE.ByteEnum.Subtract_In(a, in refValue);
                Assert.Equal(expected, refValue); // Value is updated even when passed with in keyword (matches built-in system)

                refValue = b;
                NativeExportsNE.ByteEnum.Subtract_Ref(a, ref refValue);
                Assert.Equal(expected, refValue);
            }
        }
Ejemplo n.º 14
0
		public void Init()
		{
			_type = typeof (string);
			_type2 = typeof (SomeValues);
			_dbnull = DBNull.Value;
			_assembly = typeof (SomeValues).Assembly;
			_intEnum = IntEnum.bbb;
			_byteEnum = ByteEnum.ccc;
			_bool = true;
			_bool2 = false;
			_byte = 254;
			_char = 'A';
			_dateTime = new DateTime (1972,7,13,1,20,59);
			_decimal = (decimal)101010.10101;
			_double = 123456.6789;
			_short = -19191;
			_int = -28282828;
			_long = 37373737373;
			_sbyte = -123;
			_float = (float)654321.321;
			_ushort = 61616;
			_uint = 464646464;
			_ulong = 55555555;

			Point p = new Point();
			p.x = 56; p.y = 67;
			object boxedPoint = p;

			long i = 22;
			object boxedLong = i;

			_objects = new object[] { "string", (int)1234, null , /*boxedPoint, boxedPoint,*/ boxedLong, boxedLong};
			_strings = new string[] { "an", "array", "of", "strings","I","repeat","an", "array", "of", "strings" };
			_ints = new int[] { 4,5,6,7,8 };
			_intsMulti = new int[2,3,4] { { {1,2,3,4},{5,6,7,8},{9,10,11,12}}, { {13,14,15,16},{17,18,19,20},{21,22,23,24} } };
			_intsJagged = new int[2][] { new int[3] {1,2,3}, new int[2] {4,5} };
			_simples = new SimpleClass[] { new SimpleClass('a'),new SimpleClass('b'),new SimpleClass('c') };
			_simplesMulti = new SimpleClass[2,3] {{new SimpleClass('d'),new SimpleClass('e'),new SimpleClass('f')}, {new SimpleClass('g'),new SimpleClass('j'),new SimpleClass('h')}};
			_simplesJagged = new SimpleClass[2][] { new SimpleClass[1] { new SimpleClass('i') }, new SimpleClass[2] {null, new SimpleClass('k')}};
			_almostEmpty = new object[2000];
			_almostEmpty[1000] = 4;

			_emptyObjectArray = new object[0];
			_emptyTypeArray = new Type[0];
			_emptySimpleArray = new SimpleClass[0];
			_emptyIntArray = new int[0];
			_emptyStringArray = new string[0];
			_emptyPointArray = new Point[0];

			_doubles = new double[] { 1010101.101010, 292929.29292, 3838383.38383, 4747474.474, 56565.5656565, 0, Double.NaN, Double.MaxValue, Double.MinValue, Double.NegativeInfinity, Double.PositiveInfinity };

			_sampleDelegate = new SampleDelegate(SampleCall);
			_sampleDelegate2 = new SampleDelegate(_simples[0].SampleCall);
			_sampleDelegate3 = new SampleDelegate(new SimpleClass('x').SampleCall);
			_sampleDelegateStatic = new SampleDelegate(SampleStaticCall);
			_sampleDelegateCombined = (SampleDelegate)Delegate.Combine (new Delegate[] {_sampleDelegate, _sampleDelegate2, _sampleDelegate3, _sampleDelegateStatic });

			// This is to test that references are correctly solved
			_shared1 = new SimpleClass('A');
			_shared2 = new SimpleClass('A');
			_shared3 = _shared1;
			
			_falseSerializable = new FalseISerializable (2);
		}
Ejemplo n.º 15
0
    public static TestIntfPrx allTests(TestCommon.Application app)
    {
        Ice.Communicator communicator = app.communicator();
        string           sref         = "test:" + app.getTestEndpoint(0);

        Ice.ObjectPrx obj = communicator.stringToProxy(sref);
        test(obj != null);
        TestIntfPrx proxy = TestIntfPrxHelper.uncheckedCast(obj);

        test(proxy != null);

        Console.Out.Write("testing enum values... ");
        Console.Out.Flush();

        test((int)ByteEnum.benum1 == 0);
        test((int)ByteEnum.benum2 == 1);
        test((int)ByteEnum.benum3 == ByteConst1.value);
        test((int)ByteEnum.benum4 == ByteConst1.value + 1);
        test((int)ByteEnum.benum5 == ShortConst1.value);
        test((int)ByteEnum.benum6 == ShortConst1.value + 1);
        test((int)ByteEnum.benum7 == IntConst1.value);
        test((int)ByteEnum.benum8 == IntConst1.value + 1);
        test((int)ByteEnum.benum9 == LongConst1.value);
        test((int)ByteEnum.benum10 == LongConst1.value + 1);
        test((int)ByteEnum.benum11 == ByteConst2.value);

        test((int)ShortEnum.senum1 == 3);
        test((int)ShortEnum.senum2 == 4);
        test((int)ShortEnum.senum3 == ByteConst1.value);
        test((int)ShortEnum.senum4 == ByteConst1.value + 1);
        test((int)ShortEnum.senum5 == ShortConst1.value);
        test((int)ShortEnum.senum6 == ShortConst1.value + 1);
        test((int)ShortEnum.senum7 == IntConst1.value);
        test((int)ShortEnum.senum8 == IntConst1.value + 1);
        test((int)ShortEnum.senum9 == LongConst1.value);
        test((int)ShortEnum.senum10 == LongConst1.value + 1);
        test((int)ShortEnum.senum11 == ShortConst2.value);

        test((int)IntEnum.ienum1 == 0);
        test((int)IntEnum.ienum2 == 1);
        test((int)IntEnum.ienum3 == ByteConst1.value);
        test((int)IntEnum.ienum4 == ByteConst1.value + 1);
        test((int)IntEnum.ienum5 == ShortConst1.value);
        test((int)IntEnum.ienum6 == ShortConst1.value + 1);
        test((int)IntEnum.ienum7 == IntConst1.value);
        test((int)IntEnum.ienum8 == IntConst1.value + 1);
        test((int)IntEnum.ienum9 == LongConst1.value);
        test((int)IntEnum.ienum10 == LongConst1.value + 1);
        test((int)IntEnum.ienum11 == IntConst2.value);
        test((int)IntEnum.ienum12 == LongConst2.value);

        test((int)SimpleEnum.red == 0);
        test((int)SimpleEnum.green == 1);
        test((int)SimpleEnum.blue == 2);

        Console.Out.WriteLine("ok");

        Console.Out.Write("testing enum streaming... ");
        Console.Out.Flush();

        Ice.OutputStream ostr;
        byte[]           bytes;

        bool encoding_1_0 = communicator.getProperties().getProperty("Ice.Default.EncodingVersion").Equals("1.0");

        ostr = new Ice.OutputStream(communicator);
        ostr.writeEnum((int)ByteEnum.benum11, (int)ByteEnum.benum11);
        bytes = ostr.finished();
        test(bytes.Length == 1); // ByteEnum should require one byte

        ostr = new Ice.OutputStream(communicator);
        ostr.writeEnum((int)ShortEnum.senum11, (int)ShortEnum.senum11);
        bytes = ostr.finished();
        test(bytes.Length == (encoding_1_0 ? 2 : 5));

        ostr = new Ice.OutputStream(communicator);
        ostr.writeEnum((int)IntEnum.ienum11, (int)IntEnum.ienum12);
        bytes = ostr.finished();
        test(bytes.Length == (encoding_1_0 ? 4 : 5));

        ostr = new Ice.OutputStream(communicator);
        ostr.writeEnum((int)SimpleEnum.blue, (int)SimpleEnum.blue);
        bytes = ostr.finished();
        test(bytes.Length == 1); // SimpleEnum should require one byte

        Console.Out.WriteLine("ok");

        Console.Out.Write("testing enum operations... ");
        Console.Out.Flush();

        ByteEnum byteEnum;

        test(proxy.opByte(ByteEnum.benum1, out byteEnum) == ByteEnum.benum1);
        test(byteEnum == ByteEnum.benum1);
        test(proxy.opByte(ByteEnum.benum11, out byteEnum) == ByteEnum.benum11);
        test(byteEnum == ByteEnum.benum11);

        ShortEnum shortEnum;

        test(proxy.opShort(ShortEnum.senum1, out shortEnum) == ShortEnum.senum1);
        test(shortEnum == ShortEnum.senum1);
        test(proxy.opShort(ShortEnum.senum11, out shortEnum) == ShortEnum.senum11);
        test(shortEnum == ShortEnum.senum11);

        IntEnum intEnum;

        test(proxy.opInt(IntEnum.ienum1, out intEnum) == IntEnum.ienum1);
        test(intEnum == IntEnum.ienum1);
        test(proxy.opInt(IntEnum.ienum11, out intEnum) == IntEnum.ienum11);
        test(intEnum == IntEnum.ienum11);
        test(proxy.opInt(IntEnum.ienum12, out intEnum) == IntEnum.ienum12);
        test(intEnum == IntEnum.ienum12);

        SimpleEnum s;

        test(proxy.opSimple(SimpleEnum.green, out s) == SimpleEnum.green);
        test(s == SimpleEnum.green);

        Console.Out.WriteLine("ok");

        Console.Out.Write("testing enum sequences operations... ");
        Console.Out.Flush();

        {
            ByteEnum[] b1 = new ByteEnum[11]
            {
                ByteEnum.benum1, ByteEnum.benum2, ByteEnum.benum3, ByteEnum.benum4, ByteEnum.benum5,
                ByteEnum.benum6, ByteEnum.benum7, ByteEnum.benum8, ByteEnum.benum9, ByteEnum.benum10,
                ByteEnum.benum11
            };

            ByteEnum[] b2;
            ByteEnum[] b3 = proxy.opByteSeq(b1, out b2);

            for (int i = 0; i < b1.Length; ++i)
            {
                test(b1[i] == b2[i]);
                test(b1[i] == b3[i]);
            }
        }

        {
            ShortEnum[] s1 = new ShortEnum[11]
            {
                ShortEnum.senum1, ShortEnum.senum2, ShortEnum.senum3, ShortEnum.senum4, ShortEnum.senum5,
                ShortEnum.senum6, ShortEnum.senum7, ShortEnum.senum8, ShortEnum.senum9, ShortEnum.senum10,
                ShortEnum.senum11
            };

            ShortEnum[] s2;
            ShortEnum[] s3 = proxy.opShortSeq(s1, out s2);

            for (int i = 0; i < s1.Length; ++i)
            {
                test(s1[i] == s2[i]);
                test(s1[i] == s3[i]);
            }
        }

        {
            IntEnum[] i1 = new IntEnum[11]
            {
                IntEnum.ienum1, IntEnum.ienum2, IntEnum.ienum3, IntEnum.ienum4, IntEnum.ienum5,
                IntEnum.ienum6, IntEnum.ienum7, IntEnum.ienum8, IntEnum.ienum9, IntEnum.ienum10,
                IntEnum.ienum11
            };

            IntEnum[] i2;
            IntEnum[] i3 = proxy.opIntSeq(i1, out i2);

            for (int i = 0; i < i1.Length; ++i)
            {
                test(i1[i] == i2[i]);
                test(i1[i] == i3[i]);
            }
        }

        {
            SimpleEnum[] s1 = new SimpleEnum[3]
            {
                SimpleEnum.red, SimpleEnum.green, SimpleEnum.blue
            };

            SimpleEnum[] s2;
            SimpleEnum[] s3 = proxy.opSimpleSeq(s1, out s2);

            for (int i = 0; i < s1.Length; ++i)
            {
                test(s1[i] == s2[i]);
                test(s1[i] == s3[i]);
            }
        }

        Console.Out.WriteLine("ok");
        return(proxy);
    }
Ejemplo n.º 16
0
 public TestAttribute(ByteEnum value)
 {
 }
Ejemplo n.º 17
0
        public static ITestIntfPrx allTests(TestHelper helper)
        {
            Communicator?communicator = helper.Communicator();

            TestHelper.Assert(communicator != null);
            string sref = "test:" + helper.GetTestEndpoint(0);
            var    obj  = IObjectPrx.Parse(sref, communicator);

            TestHelper.Assert(obj != null);
            var proxy = ITestIntfPrx.UncheckedCast(obj);

            TestHelper.Assert(proxy != null);

            System.IO.TextWriter output = helper.GetWriter();

            output.Write("testing enum values... ");
            output.Flush();

            TestHelper.Assert((int)ByteEnum.benum1 == 0);
            TestHelper.Assert((int)ByteEnum.benum2 == 1);
            TestHelper.Assert((int)ByteEnum.benum3 == Constants.ByteConst1);
            TestHelper.Assert((int)ByteEnum.benum4 == Constants.ByteConst1 + 1);
            TestHelper.Assert((int)ByteEnum.benum5 == Constants.ShortConst1);
            TestHelper.Assert((int)ByteEnum.benum6 == Constants.ShortConst1 + 1);
            TestHelper.Assert((int)ByteEnum.benum7 == Constants.IntConst1);
            TestHelper.Assert((int)ByteEnum.benum8 == Constants.IntConst1 + 1);
            TestHelper.Assert((int)ByteEnum.benum9 == Constants.LongConst1);
            TestHelper.Assert((int)ByteEnum.benum10 == Constants.LongConst1 + 1);
            TestHelper.Assert((int)ByteEnum.benum11 == Constants.ByteConst2);

            TestHelper.Assert((int)ShortEnum.senum1 == 3);
            TestHelper.Assert((int)ShortEnum.senum2 == 4);
            TestHelper.Assert((int)ShortEnum.senum3 == Constants.ByteConst1);
            TestHelper.Assert((int)ShortEnum.senum4 == Constants.ByteConst1 + 1);
            TestHelper.Assert((int)ShortEnum.senum5 == Constants.ShortConst1);
            TestHelper.Assert((int)ShortEnum.senum6 == Constants.ShortConst1 + 1);
            TestHelper.Assert((int)ShortEnum.senum7 == Constants.IntConst1);
            TestHelper.Assert((int)ShortEnum.senum8 == Constants.IntConst1 + 1);
            TestHelper.Assert((int)ShortEnum.senum9 == Constants.LongConst1);
            TestHelper.Assert((int)ShortEnum.senum10 == Constants.LongConst1 + 1);
            TestHelper.Assert((int)ShortEnum.senum11 == Constants.ShortConst2);

            TestHelper.Assert((int)IntEnum.ienum1 == 0);
            TestHelper.Assert((int)IntEnum.ienum2 == 1);
            TestHelper.Assert((int)IntEnum.ienum3 == Constants.ByteConst1);
            TestHelper.Assert((int)IntEnum.ienum4 == Constants.ByteConst1 + 1);
            TestHelper.Assert((int)IntEnum.ienum5 == Constants.ShortConst1);
            TestHelper.Assert((int)IntEnum.ienum6 == Constants.ShortConst1 + 1);
            TestHelper.Assert((int)IntEnum.ienum7 == Constants.IntConst1);
            TestHelper.Assert((int)IntEnum.ienum8 == Constants.IntConst1 + 1);
            TestHelper.Assert((int)IntEnum.ienum9 == Constants.LongConst1);
            TestHelper.Assert((int)IntEnum.ienum10 == Constants.LongConst1 + 1);
            TestHelper.Assert((int)IntEnum.ienum11 == Constants.IntConst2);
            TestHelper.Assert((int)IntEnum.ienum12 == Constants.LongConst2);

            TestHelper.Assert((int)SimpleEnum.red == 0);
            TestHelper.Assert((int)SimpleEnum.green == 1);
            TestHelper.Assert((int)SimpleEnum.blue == 2);

            output.WriteLine("ok");

            output.Write("testing enum operations... ");
            output.Flush();
            {
                (ByteEnum r, ByteEnum o) = proxy.OpByte(ByteEnum.benum1);
                TestHelper.Assert(r == ByteEnum.benum1 && o == ByteEnum.benum1);
                (r, o) = proxy.OpByte(ByteEnum.benum11);
                TestHelper.Assert(r == ByteEnum.benum11 && o == ByteEnum.benum11);
            }

            {
                (ByteEnum? r, ByteEnum? o) = proxy.OpTaggedByte(ByteEnum.benum1);
                TestHelper.Assert(r == ByteEnum.benum1 && o == ByteEnum.benum1);
                (r, o) = proxy.OpTaggedByte(ByteEnum.benum11);
                TestHelper.Assert(r == ByteEnum.benum11 && o == ByteEnum.benum11);
                (r, o) = proxy.OpTaggedByte(null);
                TestHelper.Assert(r == null && o == null);
            }

            {
                (ShortEnum r, ShortEnum o) = proxy.OpShort(ShortEnum.senum1);
                TestHelper.Assert(r == ShortEnum.senum1 && o == ShortEnum.senum1);
                (r, o) = proxy.OpShort(ShortEnum.senum11);
                TestHelper.Assert(r == ShortEnum.senum11 && o == ShortEnum.senum11);
            }

            {
                (IntEnum r, IntEnum o) = proxy.OpInt(IntEnum.ienum1);
                TestHelper.Assert(r == IntEnum.ienum1 && o == IntEnum.ienum1);
                (r, o) = proxy.OpInt(IntEnum.ienum11);
                TestHelper.Assert(r == IntEnum.ienum11 && o == IntEnum.ienum11);
                (r, o) = proxy.OpInt(IntEnum.ienum12);
                TestHelper.Assert(r == IntEnum.ienum12 && o == IntEnum.ienum12);
            }

            {
                (SimpleEnum r, SimpleEnum o) = proxy.OpSimple(SimpleEnum.green);
                TestHelper.Assert(r == SimpleEnum.green && o == SimpleEnum.green);
            }

            {
                (FLByteEnum r, FLByteEnum o) = proxy.OpFLByte(FLByteEnum.benum1);
                TestHelper.Assert(r == FLByteEnum.benum1 && o == FLByteEnum.benum1);
                (r, o) = proxy.OpFLByte(FLByteEnum.benum11);
                TestHelper.Assert(r == FLByteEnum.benum11 && o == FLByteEnum.benum11);
            }

            {
                (FLByteEnum? r, FLByteEnum? o) = proxy.OpTaggedFLByte(FLByteEnum.benum1);
                TestHelper.Assert(r == FLByteEnum.benum1 && o == FLByteEnum.benum1);
                (r, o) = proxy.OpTaggedFLByte(FLByteEnum.benum11);
                TestHelper.Assert(r == FLByteEnum.benum11 && o == FLByteEnum.benum11);
                (r, o) = proxy.OpTaggedFLByte(null);
                TestHelper.Assert(r == null && o == null);
            }

            {
                (FLShortEnum r, FLShortEnum o) = proxy.OpFLShort(FLShortEnum.senum1);
                TestHelper.Assert(r == FLShortEnum.senum1 && o == FLShortEnum.senum1);
                (r, o) = proxy.OpFLShort(FLShortEnum.senum11);
                TestHelper.Assert(r == FLShortEnum.senum11 && o == FLShortEnum.senum11);
            }

            {
                (FLUShortEnum r, FLUShortEnum o) = proxy.OpFLUShort(FLUShortEnum.senum1);
                TestHelper.Assert(r == FLUShortEnum.senum1 && o == FLUShortEnum.senum1);
                (r, o) = proxy.OpFLUShort(FLUShortEnum.senum11);
                TestHelper.Assert(r == FLUShortEnum.senum11 && o == FLUShortEnum.senum11);
            }

            {
                (FLIntEnum r, FLIntEnum o) = proxy.OpFLInt(FLIntEnum.ienum1);
                TestHelper.Assert(r == FLIntEnum.ienum1 && o == FLIntEnum.ienum1);
                (r, o) = proxy.OpFLInt(FLIntEnum.ienum11);
                TestHelper.Assert(r == FLIntEnum.ienum11 && o == FLIntEnum.ienum11);
                (r, o) = proxy.OpFLInt(FLIntEnum.ienum12);
                TestHelper.Assert(r == FLIntEnum.ienum12 && o == FLIntEnum.ienum12);
            }

            {
                (FLUIntEnum r, FLUIntEnum o) = proxy.OpFLUInt(FLUIntEnum.ienum1);
                TestHelper.Assert(r == FLUIntEnum.ienum1 && o == FLUIntEnum.ienum1);
                (r, o) = proxy.OpFLUInt(FLUIntEnum.ienum11);
                TestHelper.Assert(r == FLUIntEnum.ienum11 && o == FLUIntEnum.ienum11);
                (r, o) = proxy.OpFLUInt(FLUIntEnum.ienum12);
                TestHelper.Assert(r == FLUIntEnum.ienum12 && o == FLUIntEnum.ienum12);
            }

            {
                (FLSimpleEnum r, FLSimpleEnum o) = proxy.OpFLSimple(FLSimpleEnum.green);
                TestHelper.Assert(r == FLSimpleEnum.green && o == FLSimpleEnum.green);
            }

            output.WriteLine("ok");

            output.Write("testing enum sequences operations... ");
            output.Flush();

            {
                var b1 = new ByteEnum[11]
                {
                    ByteEnum.benum1,
                    ByteEnum.benum2,
                    ByteEnum.benum3,
                    ByteEnum.benum4,
                    ByteEnum.benum5,
                    ByteEnum.benum6,
                    ByteEnum.benum7,
                    ByteEnum.benum8,
                    ByteEnum.benum9,
                    ByteEnum.benum10,
                    ByteEnum.benum11
                };

                (ByteEnum[] b3, ByteEnum[] b2) = proxy.OpByteSeq(b1);
                TestHelper.Assert(b1.SequenceEqual(b2));
                TestHelper.Assert(b1.SequenceEqual(b3));
            }

            {
                var s1 = new ShortEnum[11]
                {
                    ShortEnum.senum1,
                    ShortEnum.senum2,
                    ShortEnum.senum3,
                    ShortEnum.senum4,
                    ShortEnum.senum5,
                    ShortEnum.senum6,
                    ShortEnum.senum7,
                    ShortEnum.senum8,
                    ShortEnum.senum9,
                    ShortEnum.senum10,
                    ShortEnum.senum11
                };

                (ShortEnum[] s3, ShortEnum[] s2) = proxy.OpShortSeq(s1);
                TestHelper.Assert(s1.SequenceEqual(s2));
                TestHelper.Assert(s1.SequenceEqual(s3));
            }

            {
                var i1 = new IntEnum[11]
                {
                    IntEnum.ienum1,
                    IntEnum.ienum2,
                    IntEnum.ienum3,
                    IntEnum.ienum4,
                    IntEnum.ienum5,
                    IntEnum.ienum6,
                    IntEnum.ienum7,
                    IntEnum.ienum8,
                    IntEnum.ienum9,
                    IntEnum.ienum10,
                    IntEnum.ienum11
                };

                (IntEnum[] i3, IntEnum[] i2) = proxy.OpIntSeq(i1);
                TestHelper.Assert(i1.SequenceEqual(i2));
                TestHelper.Assert(i1.SequenceEqual(i3));
            }

            {
                var s1 = new SimpleEnum[3]
                {
                    SimpleEnum.red,
                    SimpleEnum.green,
                    SimpleEnum.blue
                };

                (SimpleEnum[] s3, SimpleEnum[] s2) = proxy.OpSimpleSeq(s1);
                TestHelper.Assert(s1.SequenceEqual(s2));
                TestHelper.Assert(s1.SequenceEqual(s3));
            }

            {
                var b1 = new FLByteEnum[11]
                {
                    FLByteEnum.benum1,
                    FLByteEnum.benum2,
                    FLByteEnum.benum3,
                    FLByteEnum.benum4,
                    FLByteEnum.benum5,
                    FLByteEnum.benum6,
                    FLByteEnum.benum7,
                    FLByteEnum.benum8,
                    FLByteEnum.benum9,
                    FLByteEnum.benum10,
                    FLByteEnum.benum11
                };

                (FLByteEnum[] b3, FLByteEnum[] b2) = proxy.OpFLByteSeq(b1);
                TestHelper.Assert(b1.SequenceEqual(b2));
                TestHelper.Assert(b1.SequenceEqual(b3));
            }

            {
                var s1 = new FLShortEnum[11]
                {
                    FLShortEnum.senum1,
                    FLShortEnum.senum2,
                    FLShortEnum.senum3,
                    FLShortEnum.senum4,
                    FLShortEnum.senum5,
                    FLShortEnum.senum6,
                    FLShortEnum.senum7,
                    FLShortEnum.senum8,
                    FLShortEnum.senum9,
                    FLShortEnum.senum10,
                    FLShortEnum.senum11
                };

                (FLShortEnum[] s3, FLShortEnum[] s2) = proxy.OpFLShortSeq(s1);
                TestHelper.Assert(s1.SequenceEqual(s2));
                TestHelper.Assert(s1.SequenceEqual(s3));
            }

            {
                var s1 = new FLUShortEnum[11]
                {
                    FLUShortEnum.senum1,
                    FLUShortEnum.senum2,
                    FLUShortEnum.senum3,
                    FLUShortEnum.senum4,
                    FLUShortEnum.senum5,
                    FLUShortEnum.senum6,
                    FLUShortEnum.senum7,
                    FLUShortEnum.senum8,
                    FLUShortEnum.senum9,
                    FLUShortEnum.senum10,
                    FLUShortEnum.senum11
                };

                (FLUShortEnum[] s3, FLUShortEnum[] s2) = proxy.OpFLUShortSeq(s1);
                TestHelper.Assert(s1.SequenceEqual(s2));
                TestHelper.Assert(s1.SequenceEqual(s3));
            }

            {
                var i1 = new FLIntEnum[11]
                {
                    FLIntEnum.ienum1,
                    FLIntEnum.ienum2,
                    FLIntEnum.ienum3,
                    FLIntEnum.ienum4,
                    FLIntEnum.ienum5,
                    FLIntEnum.ienum6,
                    FLIntEnum.ienum7,
                    FLIntEnum.ienum8,
                    FLIntEnum.ienum9,
                    FLIntEnum.ienum10,
                    FLIntEnum.ienum11
                };

                (FLIntEnum[] i3, FLIntEnum[] i2) = proxy.OpFLIntSeq(i1);
                TestHelper.Assert(i1.SequenceEqual(i2));
                TestHelper.Assert(i1.SequenceEqual(i3));
            }

            {
                var i1 = new FLUIntEnum[11]
                {
                    FLUIntEnum.ienum1,
                    FLUIntEnum.ienum2,
                    FLUIntEnum.ienum3,
                    FLUIntEnum.ienum4,
                    FLUIntEnum.ienum5,
                    FLUIntEnum.ienum6,
                    FLUIntEnum.ienum7,
                    FLUIntEnum.ienum8,
                    FLUIntEnum.ienum9,
                    FLUIntEnum.ienum10,
                    FLUIntEnum.ienum11
                };

                (FLUIntEnum[] i3, FLUIntEnum[] i2) = proxy.OpFLUIntSeq(i1);
                TestHelper.Assert(i1.SequenceEqual(i2));
                TestHelper.Assert(i1.SequenceEqual(i3));
            }

            {
                var s1 = new FLSimpleEnum[3]
                {
                    FLSimpleEnum.red,
                    FLSimpleEnum.green,
                    FLSimpleEnum.blue
                };

                (FLSimpleEnum[] s3, FLSimpleEnum[] s2) = proxy.OpFLSimpleSeq(s1);
                TestHelper.Assert(s1.SequenceEqual(s2));
                TestHelper.Assert(s1.SequenceEqual(s3));
            }

            {
                var b1 = new ByteEnum[11]
                {
                    ByteEnum.benum1,
                    ByteEnum.benum2,
                    ByteEnum.benum3,
                    ByteEnum.benum4,
                    ByteEnum.benum5,
                    ByteEnum.benum6,
                    ByteEnum.benum7,
                    ByteEnum.benum8,
                    ByteEnum.benum9,
                    ByteEnum.benum10,
                    ByteEnum.benum11
                };

                (ByteEnum[]? b3, ByteEnum[]? b2) = proxy.OpTaggedByteSeq(b1);
                TestHelper.Assert(b2 != null && b3 != null);

                TestHelper.Assert(b1.SequenceEqual(b2));
                TestHelper.Assert(b1.SequenceEqual(b3));

                (b3, b2) = proxy.OpTaggedByteSeq(null);
                TestHelper.Assert(b2 == null && b3 == null);
            }

            {
                var b1 = new FLByteEnum[11]
                {
                    FLByteEnum.benum1,
                    FLByteEnum.benum2,
                    FLByteEnum.benum3,
                    FLByteEnum.benum4,
                    FLByteEnum.benum5,
                    FLByteEnum.benum6,
                    FLByteEnum.benum7,
                    FLByteEnum.benum8,
                    FLByteEnum.benum9,
                    FLByteEnum.benum10,
                    FLByteEnum.benum11
                };

                (FLByteEnum[]? b3, FLByteEnum[]? b2) = proxy.OpTaggedFLByteSeq(b1);
                TestHelper.Assert(b2 != null && b3 != null);

                TestHelper.Assert(b1.SequenceEqual(b2));
                TestHelper.Assert(b1.SequenceEqual(b3));

                (b3, b2) = proxy.OpTaggedFLByteSeq(null);
                TestHelper.Assert(b2 == null && b3 == null);
            }

            {
                var i1 = new FLIntEnum[11]
                {
                    FLIntEnum.ienum1,
                    FLIntEnum.ienum2,
                    FLIntEnum.ienum3,
                    FLIntEnum.ienum4,
                    FLIntEnum.ienum5,
                    FLIntEnum.ienum6,
                    FLIntEnum.ienum7,
                    FLIntEnum.ienum8,
                    FLIntEnum.ienum9,
                    FLIntEnum.ienum10,
                    FLIntEnum.ienum11
                };

                (FLIntEnum[]? i3, FLIntEnum[]? i2) = proxy.OpTaggedFLIntSeq(i1);
                TestHelper.Assert(i2 != null && i3 != null);

                TestHelper.Assert(i1.SequenceEqual(i2));
                TestHelper.Assert(i1.SequenceEqual(i3));

                (i3, i2) = proxy.OpTaggedFLIntSeq(null);
                TestHelper.Assert(i2 == null && i3 == null);
            }

            output.WriteLine("ok");
            return(proxy);
        }
Ejemplo n.º 18
0
 public (ByteEnum, ByteEnum) OpByte(ByteEnum b1, Current current) => (b1, b1);
Ejemplo n.º 19
0
 public (ByteEnum, ByteEnum) OpByte(ByteEnum b1, Current current, CancellationToken cancel) => (b1, b1);
Ejemplo n.º 20
0
        public static async Task RunAsync(TestHelper helper)
        {
            Communicator communicator = helper.Communicator;

            var proxy = ITestIntfPrx.Parse(helper.GetTestProxy("test", 0), communicator);

            System.IO.TextWriter output = helper.Output;

            output.Write("testing enum values... ");
            output.Flush();

            TestHelper.Assert((int)ByteEnum.benum1 == 0);
            TestHelper.Assert((int)ByteEnum.benum2 == 1);
            TestHelper.Assert((int)ByteEnum.benum3 == Constants.ByteConst1);
            TestHelper.Assert((int)ByteEnum.benum4 == Constants.ByteConst1 + 1);
            TestHelper.Assert((int)ByteEnum.benum5 == Constants.ShortConst1);
            TestHelper.Assert((int)ByteEnum.benum6 == Constants.ShortConst1 + 1);
            TestHelper.Assert((int)ByteEnum.benum7 == Constants.IntConst1);
            TestHelper.Assert((int)ByteEnum.benum8 == Constants.IntConst1 + 1);
            TestHelper.Assert((int)ByteEnum.benum9 == Constants.LongConst1);
            TestHelper.Assert((int)ByteEnum.benum10 == Constants.LongConst1 + 1);
            TestHelper.Assert((int)ByteEnum.benum11 == Constants.ByteConst2);

            TestHelper.Assert((int)ShortEnum.senum1 == 3);
            TestHelper.Assert((int)ShortEnum.senum2 == 4);
            TestHelper.Assert((int)ShortEnum.senum3 == Constants.ByteConst1);
            TestHelper.Assert((int)ShortEnum.senum4 == Constants.ByteConst1 + 1);
            TestHelper.Assert((int)ShortEnum.senum5 == Constants.ShortConst1);
            TestHelper.Assert((int)ShortEnum.senum6 == Constants.ShortConst1 + 1);
            TestHelper.Assert((int)ShortEnum.senum7 == Constants.IntConst1);
            TestHelper.Assert((int)ShortEnum.senum8 == Constants.IntConst1 + 1);
            TestHelper.Assert((int)ShortEnum.senum9 == Constants.LongConst1);
            TestHelper.Assert((int)ShortEnum.senum10 == Constants.LongConst1 + 1);
            TestHelper.Assert((int)ShortEnum.senum11 == Constants.ShortConst2);

            TestHelper.Assert((int)IntEnum.ienum1 == 0);
            TestHelper.Assert((int)IntEnum.ienum2 == 1);
            TestHelper.Assert((int)IntEnum.ienum3 == Constants.ByteConst1);
            TestHelper.Assert((int)IntEnum.ienum4 == Constants.ByteConst1 + 1);
            TestHelper.Assert((int)IntEnum.ienum5 == Constants.ShortConst1);
            TestHelper.Assert((int)IntEnum.ienum6 == Constants.ShortConst1 + 1);
            TestHelper.Assert((int)IntEnum.ienum7 == Constants.IntConst1);
            TestHelper.Assert((int)IntEnum.ienum8 == Constants.IntConst1 + 1);
            TestHelper.Assert((int)IntEnum.ienum9 == Constants.LongConst1);
            TestHelper.Assert((int)IntEnum.ienum10 == Constants.LongConst1 + 1);
            TestHelper.Assert((int)IntEnum.ienum11 == Constants.IntConst2);
            TestHelper.Assert((int)IntEnum.ienum12 == Constants.LongConst2);

            TestHelper.Assert((int)SimpleEnum.red == 0);
            TestHelper.Assert((int)SimpleEnum.green == 1);
            TestHelper.Assert((int)SimpleEnum.blue == 2);

            output.WriteLine("ok");

            output.Write("testing enum operations... ");
            output.Flush();
            {
                (ByteEnum r, ByteEnum o) = proxy.OpByte(ByteEnum.benum1);
                TestHelper.Assert(r == ByteEnum.benum1 && o == ByteEnum.benum1);
                (r, o) = proxy.OpByte(ByteEnum.benum11);
                TestHelper.Assert(r == ByteEnum.benum11 && o == ByteEnum.benum11);
            }

            {
                // 42 does not correspond to a ByteEnum enumerator, so we expect failure since ByteEnum is checked.
                try
                {
                    _ = proxy.OpByte((ByteEnum)42);
                    TestHelper.Assert(false);
                }
                catch (UnhandledException) // unhandled dispatch exception
                {
                    // expected
                }
            }

            {
                (ByteEnum? r, ByteEnum? o) = proxy.OpTaggedByte(ByteEnum.benum1);
                TestHelper.Assert(r == ByteEnum.benum1 && o == ByteEnum.benum1);
                (r, o) = proxy.OpTaggedByte(ByteEnum.benum11);
                TestHelper.Assert(r == ByteEnum.benum11 && o == ByteEnum.benum11);
                (r, o) = proxy.OpTaggedByte(null);
                TestHelper.Assert(r == null && o == null);
            }

            {
                try
                {
                    _ = proxy.OpTaggedByte((ByteEnum)42);
                    TestHelper.Assert(false);
                }
                catch (UnhandledException) // unhandled dispatch exception
                {
                    // expected
                }
            }

            {
                (ShortEnum r, ShortEnum o) = proxy.OpShort(ShortEnum.senum1);
                TestHelper.Assert(r == ShortEnum.senum1 && o == ShortEnum.senum1);
                (r, o) = proxy.OpShort(ShortEnum.senum11);
                TestHelper.Assert(r == ShortEnum.senum11 && o == ShortEnum.senum11);
            }

            {
                (IntEnum r, IntEnum o) = proxy.OpInt(IntEnum.ienum1);
                TestHelper.Assert(r == IntEnum.ienum1 && o == IntEnum.ienum1);
                (r, o) = proxy.OpInt(IntEnum.ienum11);
                TestHelper.Assert(r == IntEnum.ienum11 && o == IntEnum.ienum11);
                (r, o) = proxy.OpInt(IntEnum.ienum12);
                TestHelper.Assert(r == IntEnum.ienum12 && o == IntEnum.ienum12);
            }

            {
                (SimpleEnum r, SimpleEnum o) = proxy.OpSimple(SimpleEnum.green);
                TestHelper.Assert(r == SimpleEnum.green && o == SimpleEnum.green);
            }

            {
                (FLByteEnum r, FLByteEnum o) = proxy.OpFLByte(FLByteEnum.benum1);
                TestHelper.Assert(r == FLByteEnum.benum1 && o == FLByteEnum.benum1);
                (r, o) = proxy.OpFLByte(FLByteEnum.benum11);
                TestHelper.Assert(r == FLByteEnum.benum11 && o == FLByteEnum.benum11);
            }

            {
                (FLByteEnum? r, FLByteEnum? o) = proxy.OpTaggedFLByte(FLByteEnum.benum1);
                TestHelper.Assert(r == FLByteEnum.benum1 && o == FLByteEnum.benum1);
                (r, o) = proxy.OpTaggedFLByte(FLByteEnum.benum11);
                TestHelper.Assert(r == FLByteEnum.benum11 && o == FLByteEnum.benum11);
                (r, o) = proxy.OpTaggedFLByte(null);
                TestHelper.Assert(r == null && o == null);
            }

            {
                (FLShortEnum r, FLShortEnum o) = proxy.OpFLShort(FLShortEnum.senum1);
                TestHelper.Assert(r == FLShortEnum.senum1 && o == FLShortEnum.senum1);
                (r, o) = proxy.OpFLShort(FLShortEnum.senum11);
                TestHelper.Assert(r == FLShortEnum.senum11 && o == FLShortEnum.senum11);
            }

            {
                (FLUShortEnum r, FLUShortEnum o) = proxy.OpFLUShort(FLUShortEnum.senum1);
                TestHelper.Assert(r == FLUShortEnum.senum1 && o == FLUShortEnum.senum1);
                (r, o) = proxy.OpFLUShort(FLUShortEnum.senum11);
                TestHelper.Assert(r == FLUShortEnum.senum11 && o == FLUShortEnum.senum11);
            }

            {
                (FLIntEnum r, FLIntEnum o) = proxy.OpFLInt(FLIntEnum.ienum1);
                TestHelper.Assert(r == FLIntEnum.ienum1 && o == FLIntEnum.ienum1);
                (r, o) = proxy.OpFLInt(FLIntEnum.ienum11);
                TestHelper.Assert(r == FLIntEnum.ienum11 && o == FLIntEnum.ienum11);
                (r, o) = proxy.OpFLInt(FLIntEnum.ienum12);
                TestHelper.Assert(r == FLIntEnum.ienum12 && o == FLIntEnum.ienum12);
            }

            {
                (FLUIntEnum r, FLUIntEnum o) = proxy.OpFLUInt(FLUIntEnum.ienum1);
                TestHelper.Assert(r == FLUIntEnum.ienum1 && o == FLUIntEnum.ienum1);
                (r, o) = proxy.OpFLUInt(FLUIntEnum.ienum11);
                TestHelper.Assert(r == FLUIntEnum.ienum11 && o == FLUIntEnum.ienum11);
                (r, o) = proxy.OpFLUInt(FLUIntEnum.ienum12);
                TestHelper.Assert(r == FLUIntEnum.ienum12 && o == FLUIntEnum.ienum12);
            }

            {
                (FLSimpleEnum r, FLSimpleEnum o) = proxy.OpFLSimple(FLSimpleEnum.green);
                TestHelper.Assert(r == FLSimpleEnum.green && o == FLSimpleEnum.green);
            }

            output.WriteLine("ok");

            output.Write("testing enum sequences operations... ");
            output.Flush();

            {
                var b1 = new ByteEnum[11]
                {
                    ByteEnum.benum1,
                    ByteEnum.benum2,
                    ByteEnum.benum3,
                    ByteEnum.benum4,
                    ByteEnum.benum5,
                    ByteEnum.benum6,
                    ByteEnum.benum7,
                    ByteEnum.benum8,
                    ByteEnum.benum9,
                    ByteEnum.benum10,
                    ByteEnum.benum11
                };

                (ByteEnum[] b3, ByteEnum[] b2) = proxy.OpByteSeq(b1);
                TestHelper.Assert(b1.SequenceEqual(b2));
                TestHelper.Assert(b1.SequenceEqual(b3));
            }

            {
                var b1 = new ByteEnum[12]
                {
                    ByteEnum.benum1,
                    ByteEnum.benum2,
                    (ByteEnum)42,
                    ByteEnum.benum3,
                    ByteEnum.benum4,
                    ByteEnum.benum5,
                    ByteEnum.benum6,
                    ByteEnum.benum7,
                    ByteEnum.benum8,
                    ByteEnum.benum9,
                    ByteEnum.benum10,
                    ByteEnum.benum11
                };

                try
                {
                    _ = proxy.OpByteSeq(b1);
                    TestHelper.Assert(false);
                }
                catch (UnhandledException)
                {
                    // expected
                }
            }

            {
                var s1 = new ShortEnum[11]
                {
                    ShortEnum.senum1,
                    ShortEnum.senum2,
                    ShortEnum.senum3,
                    ShortEnum.senum4,
                    ShortEnum.senum5,
                    ShortEnum.senum6,
                    ShortEnum.senum7,
                    ShortEnum.senum8,
                    ShortEnum.senum9,
                    ShortEnum.senum10,
                    ShortEnum.senum11
                };

                (ShortEnum[] s3, ShortEnum[] s2) = proxy.OpShortSeq(s1);
                TestHelper.Assert(s1.SequenceEqual(s2));
                TestHelper.Assert(s1.SequenceEqual(s3));
            }

            {
                var i1 = new IntEnum[11]
                {
                    IntEnum.ienum1,
                    IntEnum.ienum2,
                    IntEnum.ienum3,
                    IntEnum.ienum4,
                    IntEnum.ienum5,
                    IntEnum.ienum6,
                    IntEnum.ienum7,
                    IntEnum.ienum8,
                    IntEnum.ienum9,
                    IntEnum.ienum10,
                    IntEnum.ienum11
                };

                (IntEnum[] i3, IntEnum[] i2) = proxy.OpIntSeq(i1);
                TestHelper.Assert(i1.SequenceEqual(i2));
                TestHelper.Assert(i1.SequenceEqual(i3));
            }

            {
                var s1 = new SimpleEnum[3]
                {
                    SimpleEnum.red,
                    SimpleEnum.green,
                    SimpleEnum.blue
                };

                (SimpleEnum[] s3, SimpleEnum[] s2) = proxy.OpSimpleSeq(s1);
                TestHelper.Assert(s1.SequenceEqual(s2));
                TestHelper.Assert(s1.SequenceEqual(s3));
            }

            {
                var b1 = new FLByteEnum[11]
                {
                    FLByteEnum.benum1,
                    FLByteEnum.benum2,
                    FLByteEnum.benum3,
                    FLByteEnum.benum4,
                    FLByteEnum.benum5,
                    FLByteEnum.benum6,
                    FLByteEnum.benum7,
                    FLByteEnum.benum8,
                    FLByteEnum.benum9,
                    FLByteEnum.benum10,
                    FLByteEnum.benum11
                };

                (FLByteEnum[] b3, FLByteEnum[] b2) = proxy.OpFLByteSeq(b1);
                TestHelper.Assert(b1.SequenceEqual(b2));
                TestHelper.Assert(b1.SequenceEqual(b3));
            }

            {
                var s1 = new FLShortEnum[11]
                {
                    FLShortEnum.senum1,
                    FLShortEnum.senum2,
                    FLShortEnum.senum3,
                    FLShortEnum.senum4,
                    FLShortEnum.senum5,
                    FLShortEnum.senum6,
                    FLShortEnum.senum7,
                    FLShortEnum.senum8,
                    FLShortEnum.senum9,
                    FLShortEnum.senum10,
                    FLShortEnum.senum11
                };

                (FLShortEnum[] s3, FLShortEnum[] s2) = proxy.OpFLShortSeq(s1);
                TestHelper.Assert(s1.SequenceEqual(s2));
                TestHelper.Assert(s1.SequenceEqual(s3));
            }

            {
                var s1 = new FLUShortEnum[11]
                {
                    FLUShortEnum.senum1,
                    FLUShortEnum.senum2,
                    FLUShortEnum.senum3,
                    FLUShortEnum.senum4,
                    FLUShortEnum.senum5,
                    FLUShortEnum.senum6,
                    FLUShortEnum.senum7,
                    FLUShortEnum.senum8,
                    FLUShortEnum.senum9,
                    FLUShortEnum.senum10,
                    FLUShortEnum.senum11
                };

                (FLUShortEnum[] s3, FLUShortEnum[] s2) = proxy.OpFLUShortSeq(s1);
                TestHelper.Assert(s1.SequenceEqual(s2));
                TestHelper.Assert(s1.SequenceEqual(s3));
            }

            {
                var i1 = new FLIntEnum[11]
                {
                    FLIntEnum.ienum1,
                    FLIntEnum.ienum2,
                    FLIntEnum.ienum3,
                    FLIntEnum.ienum4,
                    FLIntEnum.ienum5,
                    FLIntEnum.ienum6,
                    FLIntEnum.ienum7,
                    FLIntEnum.ienum8,
                    FLIntEnum.ienum9,
                    FLIntEnum.ienum10,
                    FLIntEnum.ienum11
                };

                (FLIntEnum[] i3, FLIntEnum[] i2) = proxy.OpFLIntSeq(i1);
                TestHelper.Assert(i1.SequenceEqual(i2));
                TestHelper.Assert(i1.SequenceEqual(i3));
            }

            {
                var i1 = new FLUIntEnum[11]
                {
                    FLUIntEnum.ienum1,
                    FLUIntEnum.ienum2,
                    FLUIntEnum.ienum3,
                    FLUIntEnum.ienum4,
                    FLUIntEnum.ienum5,
                    FLUIntEnum.ienum6,
                    FLUIntEnum.ienum7,
                    FLUIntEnum.ienum8,
                    FLUIntEnum.ienum9,
                    FLUIntEnum.ienum10,
                    FLUIntEnum.ienum11
                };

                (FLUIntEnum[] i3, FLUIntEnum[] i2) = proxy.OpFLUIntSeq(i1);
                TestHelper.Assert(i1.SequenceEqual(i2));
                TestHelper.Assert(i1.SequenceEqual(i3));
            }

            {
                var s1 = new FLSimpleEnum[3]
                {
                    FLSimpleEnum.red,
                    FLSimpleEnum.green,
                    FLSimpleEnum.blue
                };

                (FLSimpleEnum[] s3, FLSimpleEnum[] s2) = proxy.OpFLSimpleSeq(s1);
                TestHelper.Assert(s1.SequenceEqual(s2));
                TestHelper.Assert(s1.SequenceEqual(s3));
            }

            {
                var b1 = new ByteEnum[11]
                {
                    ByteEnum.benum1,
                    ByteEnum.benum2,
                    ByteEnum.benum3,
                    ByteEnum.benum4,
                    ByteEnum.benum5,
                    ByteEnum.benum6,
                    ByteEnum.benum7,
                    ByteEnum.benum8,
                    ByteEnum.benum9,
                    ByteEnum.benum10,
                    ByteEnum.benum11
                };

                (ByteEnum[]? b3, ByteEnum[]? b2) = proxy.OpTaggedByteSeq(b1);
                TestHelper.Assert(b2 != null && b3 != null);

                TestHelper.Assert(b1.SequenceEqual(b2));
                TestHelper.Assert(b1.SequenceEqual(b3));

                (b3, b2) = proxy.OpTaggedByteSeq(null);
                TestHelper.Assert(b2 == null && b3 == null);
            }

            {
                var b1 = new ByteEnum[12]
                {
                    ByteEnum.benum1,
                    ByteEnum.benum2,
                    ByteEnum.benum3,
                    ByteEnum.benum4,
                    ByteEnum.benum5,
                    ByteEnum.benum6,
                    ByteEnum.benum7,
                    ByteEnum.benum8,
                    (ByteEnum)42,
                    ByteEnum.benum9,
                    ByteEnum.benum10,
                    ByteEnum.benum11
                };

                try
                {
                    _ = proxy.OpTaggedByteSeq(b1);
                    TestHelper.Assert(false);
                }
                catch (UnhandledException)
                {
                    // expected
                }
            }

            {
                var b1 = new FLByteEnum[11]
                {
                    FLByteEnum.benum1,
                    FLByteEnum.benum2,
                    FLByteEnum.benum3,
                    FLByteEnum.benum4,
                    FLByteEnum.benum5,
                    FLByteEnum.benum6,
                    FLByteEnum.benum7,
                    FLByteEnum.benum8,
                    FLByteEnum.benum9,
                    FLByteEnum.benum10,
                    FLByteEnum.benum11
                };

                (FLByteEnum[]? b3, FLByteEnum[]? b2) = proxy.OpTaggedFLByteSeq(b1);
                TestHelper.Assert(b2 != null && b3 != null);

                TestHelper.Assert(b1.SequenceEqual(b2));
                TestHelper.Assert(b1.SequenceEqual(b3));

                (b3, b2) = proxy.OpTaggedFLByteSeq(null);
                TestHelper.Assert(b2 == null && b3 == null);
            }

            {
                var i1 = new FLIntEnum[11]
                {
                    FLIntEnum.ienum1,
                    FLIntEnum.ienum2,
                    FLIntEnum.ienum3,
                    FLIntEnum.ienum4,
                    FLIntEnum.ienum5,
                    FLIntEnum.ienum6,
                    FLIntEnum.ienum7,
                    FLIntEnum.ienum8,
                    FLIntEnum.ienum9,
                    FLIntEnum.ienum10,
                    FLIntEnum.ienum11
                };

                (FLIntEnum[]? i3, FLIntEnum[]? i2) = proxy.OpTaggedFLIntSeq(i1);
                TestHelper.Assert(i2 != null && i3 != null);

                TestHelper.Assert(i1.SequenceEqual(i2));
                TestHelper.Assert(i1.SequenceEqual(i3));

                (i3, i2) = proxy.OpTaggedFLIntSeq(null);
                TestHelper.Assert(i2 == null && i3 == null);
            }

            output.WriteLine("ok");

            output.Write("testing unchecked enums... ");
            output.Flush();
            {
                (MyFlags r, MyFlags f2) = proxy.OpMyFlags(MyFlags.E31);
                TestHelper.Assert(r == MyFlags.E31 && f2 == r);
                (r, f2) = proxy.OpMyFlags(MyFlags.E10 | MyFlags.E11);
                TestHelper.Assert(r == (MyFlags.E10 | MyFlags.E11) && f2 == r);
            }

            output.Flush();
            {
                (MyFlags? r, MyFlags? f2) = proxy.OpTaggedMyFlags(null);
                TestHelper.Assert(r == null && f2 == r);
                (r, f2) = proxy.OpTaggedMyFlags(MyFlags.E10 | MyFlags.E11);
                TestHelper.Assert(r == (MyFlags.E10 | MyFlags.E11) && f2 == r);
            }

            output.Flush();
            {
                var myFlagsSeq = new MyFlags[] { MyFlags.E10, MyFlags.E0, MyFlags.E5 | MyFlags.E6 };
                (MyFlags[] r, MyFlags[] f2) = proxy.OpMyFlagsSeq(myFlagsSeq);
                TestHelper.Assert(r.SequenceEqual(myFlagsSeq) && f2.SequenceEqual(myFlagsSeq));
            }

            output.Flush();
            {
                var myFlagsSeq = new MyFlags[] { MyFlags.E10, MyFlags.E0, MyFlags.E5 | MyFlags.E6 };
                (MyFlags[]? r, MyFlags[]? f2) = proxy.OpTaggedMyFlagsSeq(myFlagsSeq);
                TestHelper.Assert(r !.SequenceEqual(myFlagsSeq) && f2 !.SequenceEqual(myFlagsSeq));
            }

            output.WriteLine("ok");
            await proxy.ShutdownAsync();
        }
Ejemplo n.º 21
0
 private byte Enum1ToByte(ByteEnum value)
 {
     return((byte)value);
 }
Ejemplo n.º 22
0
 private ulong Enum1ToULong(ByteEnum value)
 {
     return((ulong)value);
 }
        public Primitives(sbyte sb, byte b, short s, ushort us, int i, uint ui, long l, ulong ul,
                          SByteEnum sbe, ByteEnum be, ShortEnum se, UShortEnum use, IntEnum ie, UIntEnum uie, LongEnum le, ULongEnum ule,
                          char c, bool bo, float f, double d,
                          string str, Type t, int[] arr, object obj)
        {
            SByteConstructor = sb;
            ByteConstructor = b;
            ShortConstructor = s;
            UShortConstructor = us;
            IntConstructor = i;
            UIntConstructor = ui;
            LongConstructor = l;
            ULongConstructor = ul;

            SByteEnumConstructor = sbe;
            ByteEnumConstructor = be;
            ShortEnumConstructor = se;
            UShortEnumConstructor = use;
            IntEnumConstructor = ie;
            UIntEnumConstructor = uie;
            LongEnumConstructor = le;
            ULongEnumConstructor = ule;

            CharConstructor = c;
            BoolConstructor = bo;
            FloatConstructor = f;
            DoubleConstructor = d;

            StringConstructor = str;
            TypeConstructor = t;
            ArrayConstructor = arr;
            ObjectConstructor = obj;
        }
Ejemplo n.º 24
0
        public void Init()
        {
            _type     = typeof(string);
            _type2    = typeof(SomeValues);
            _dbnull   = DBNull.Value;
            _assembly = typeof(SomeValues).Assembly;
            _intEnum  = IntEnum.bbb;
            _byteEnum = ByteEnum.ccc;
            _bool     = true;
            _bool2    = false;
            _byte     = 254;
            _char     = 'A';
            _dateTime = new DateTime(1972, 7, 13, 1, 20, 59);
            _decimal  = (decimal)101010.10101;
            _double   = 123456.6789;
            _short    = -19191;
            _int      = -28282828;
            _long     = 37373737373;
            _sbyte    = -123;
            _float    = (float)654321.321;
            _ushort   = 61616;
            _uint     = 464646464;
            _ulong    = 55555555;

            Point p = new Point();

            p.x = 56; p.y = 67;
            object boxedPoint = p;

            long   i         = 22;
            object boxedLong = i;

            _objects   = new object[] { "string", (int)1234, null, /*boxedPoint, boxedPoint,*/ boxedLong, boxedLong };
            _strings   = new string[] { "an", "array", "of", "strings", "I", "repeat", "an", "array", "of", "strings" };
            _ints      = new int[] { 4, 5, 6, 7, 8 };
            _intsMulti = new int[2, 3, 4] {
                { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } }, { { 13, 14, 15, 16 }, { 17, 18, 19, 20 }, { 21, 22, 23, 24 } }
            };
            _intsJagged = new int[2][] { new int[3] {
                                             1, 2, 3
                                         }, new int[2] {
                                             4, 5
                                         } };
            _simples      = new SimpleClass[] { new SimpleClass('a'), new SimpleClass('b'), new SimpleClass('c') };
            _simplesMulti = new SimpleClass[2, 3] {
                { new SimpleClass('d'), new SimpleClass('e'), new SimpleClass('f') }, { new SimpleClass('g'), new SimpleClass('j'), new SimpleClass('h') }
            };
            _simplesJagged = new SimpleClass[2][] { new SimpleClass[1] {
                                                        new SimpleClass('i')
                                                    }, new SimpleClass[2] {
                                                        null, new SimpleClass('k')
                                                    } };
            _almostEmpty       = new object[2000];
            _almostEmpty[1000] = 4;

            _emptyObjectArray = new object[0];
            _emptyTypeArray   = new Type[0];
            _emptySimpleArray = new SimpleClass[0];
            _emptyIntArray    = new int[0];
            _emptyStringArray = new string[0];

            // FIXME: Once double.ToString("G17") is implemented
            // we'll be able to serialize double.MaxValue and double.MinValue.
            // Currently, it throws a System.OverflowException.
            //_doubles = new double[] { 1010101.101010, 292929.29292, 3838383.38383, 4747474.474, 56565.5656565, 0, Double.NaN, Double.MaxValue, Double.MinValue, Double.NegativeInfinity, Double.PositiveInfinity };
            _doubles = new double[] { 1010101.101010, 292929.29292, 3838383.38383, 4747474.474, 56565.5656565, 0, Double.NaN, Double.NegativeInfinity, Double.PositiveInfinity };

            _sampleDelegate         = new SampleDelegate(SampleCall);
            _sampleDelegate2        = new SampleDelegate(_simples[0].SampleCall);
            _sampleDelegate3        = new SampleDelegate(new SimpleClass('x').SampleCall);
            _sampleDelegateStatic   = new SampleDelegate(SampleStaticCall);
            _sampleDelegateCombined = (SampleDelegate)Delegate.Combine(new Delegate[] { _sampleDelegate, _sampleDelegate2, _sampleDelegate3, _sampleDelegateStatic });

            // This is to test that references are correctly solved
            _shared1 = new SimpleClass('A');
            _shared2 = new SimpleClass('A');
            _shared3 = _shared1;
        }
Ejemplo n.º 25
0
        public static ITestIntfPrx allTests(TestHelper helper)
        {
            Communicator?communicator = helper.Communicator();

            TestHelper.Assert(communicator != null);
            string sref = "test:" + helper.GetTestEndpoint(0);
            var    obj  = IObjectPrx.Parse(sref, communicator);

            TestHelper.Assert(obj != null);
            var proxy = ITestIntfPrx.UncheckedCast(obj);

            TestHelper.Assert(proxy != null);

            System.IO.TextWriter output = helper.GetWriter();

            output.Write("testing enum values... ");
            output.Flush();

            TestHelper.Assert((int)ByteEnum.benum1 == 0);
            TestHelper.Assert((int)ByteEnum.benum2 == 1);
            TestHelper.Assert((int)ByteEnum.benum3 == Constants.ByteConst1);
            TestHelper.Assert((int)ByteEnum.benum4 == Constants.ByteConst1 + 1);
            TestHelper.Assert((int)ByteEnum.benum5 == Constants.ShortConst1);
            TestHelper.Assert((int)ByteEnum.benum6 == Constants.ShortConst1 + 1);
            TestHelper.Assert((int)ByteEnum.benum7 == Constants.IntConst1);
            TestHelper.Assert((int)ByteEnum.benum8 == Constants.IntConst1 + 1);
            TestHelper.Assert((int)ByteEnum.benum9 == Constants.LongConst1);
            TestHelper.Assert((int)ByteEnum.benum10 == Constants.LongConst1 + 1);
            TestHelper.Assert((int)ByteEnum.benum11 == Constants.ByteConst2);

            TestHelper.Assert((int)ShortEnum.senum1 == 3);
            TestHelper.Assert((int)ShortEnum.senum2 == 4);
            TestHelper.Assert((int)ShortEnum.senum3 == Constants.ByteConst1);
            TestHelper.Assert((int)ShortEnum.senum4 == Constants.ByteConst1 + 1);
            TestHelper.Assert((int)ShortEnum.senum5 == Constants.ShortConst1);
            TestHelper.Assert((int)ShortEnum.senum6 == Constants.ShortConst1 + 1);
            TestHelper.Assert((int)ShortEnum.senum7 == Constants.IntConst1);
            TestHelper.Assert((int)ShortEnum.senum8 == Constants.IntConst1 + 1);
            TestHelper.Assert((int)ShortEnum.senum9 == Constants.LongConst1);
            TestHelper.Assert((int)ShortEnum.senum10 == Constants.LongConst1 + 1);
            TestHelper.Assert((int)ShortEnum.senum11 == Constants.ShortConst2);

            TestHelper.Assert((int)IntEnum.ienum1 == 0);
            TestHelper.Assert((int)IntEnum.ienum2 == 1);
            TestHelper.Assert((int)IntEnum.ienum3 == Constants.ByteConst1);
            TestHelper.Assert((int)IntEnum.ienum4 == Constants.ByteConst1 + 1);
            TestHelper.Assert((int)IntEnum.ienum5 == Constants.ShortConst1);
            TestHelper.Assert((int)IntEnum.ienum6 == Constants.ShortConst1 + 1);
            TestHelper.Assert((int)IntEnum.ienum7 == Constants.IntConst1);
            TestHelper.Assert((int)IntEnum.ienum8 == Constants.IntConst1 + 1);
            TestHelper.Assert((int)IntEnum.ienum9 == Constants.LongConst1);
            TestHelper.Assert((int)IntEnum.ienum10 == Constants.LongConst1 + 1);
            TestHelper.Assert((int)IntEnum.ienum11 == Constants.IntConst2);
            TestHelper.Assert((int)IntEnum.ienum12 == Constants.LongConst2);

            TestHelper.Assert((int)SimpleEnum.red == 0);
            TestHelper.Assert((int)SimpleEnum.green == 1);
            TestHelper.Assert((int)SimpleEnum.blue == 2);

            output.WriteLine("ok");

            output.Write("testing enum operations... ");
            output.Flush();
            {
                (ByteEnum r, ByteEnum o) = proxy.opByte(ByteEnum.benum1);
                TestHelper.Assert(r == ByteEnum.benum1 && o == ByteEnum.benum1);
                (r, o) = proxy.opByte(ByteEnum.benum11);
                TestHelper.Assert(r == ByteEnum.benum11 && o == ByteEnum.benum11);
            }

            {
                (ShortEnum r, ShortEnum o) = proxy.opShort(ShortEnum.senum1);
                TestHelper.Assert(r == ShortEnum.senum1 && o == ShortEnum.senum1);
                (r, o) = proxy.opShort(ShortEnum.senum11);
                TestHelper.Assert(r == ShortEnum.senum11 && o == ShortEnum.senum11);
            }

            {
                (IntEnum r, IntEnum o) = proxy.opInt(IntEnum.ienum1);
                TestHelper.Assert(r == IntEnum.ienum1 && o == IntEnum.ienum1);
                (r, o) = proxy.opInt(IntEnum.ienum11);
                TestHelper.Assert(r == IntEnum.ienum11 && o == IntEnum.ienum11);
                (r, o) = proxy.opInt(IntEnum.ienum12);
                TestHelper.Assert(r == IntEnum.ienum12 && o == IntEnum.ienum12);
            }

            {
                (SimpleEnum r, SimpleEnum o) = proxy.opSimple(SimpleEnum.green);
                TestHelper.Assert(r == SimpleEnum.green && o == SimpleEnum.green);
            }

            output.WriteLine("ok");

            output.Write("testing enum sequences operations... ");
            output.Flush();

            {
                var b1 = new ByteEnum[11]
                {
                    ByteEnum.benum1,
                    ByteEnum.benum2,
                    ByteEnum.benum3,
                    ByteEnum.benum4,
                    ByteEnum.benum5,
                    ByteEnum.benum6,
                    ByteEnum.benum7,
                    ByteEnum.benum8,
                    ByteEnum.benum9,
                    ByteEnum.benum10,
                    ByteEnum.benum11
                };

                (ByteEnum[] b3, ByteEnum[] b2) = proxy.opByteSeq(b1);

                for (int i = 0; i < b1.Length; ++i)
                {
                    TestHelper.Assert(b1[i] == b2[i]);
                    TestHelper.Assert(b1[i] == b3[i]);
                }
            }

            {
                var s1 = new ShortEnum[11]
                {
                    ShortEnum.senum1,
                    ShortEnum.senum2,
                    ShortEnum.senum3,
                    ShortEnum.senum4,
                    ShortEnum.senum5,
                    ShortEnum.senum6,
                    ShortEnum.senum7,
                    ShortEnum.senum8,
                    ShortEnum.senum9,
                    ShortEnum.senum10,
                    ShortEnum.senum11
                };

                (ShortEnum[] s3, ShortEnum[] s2) = proxy.opShortSeq(s1);

                for (int i = 0; i < s1.Length; ++i)
                {
                    TestHelper.Assert(s1[i] == s2[i]);
                    TestHelper.Assert(s1[i] == s3[i]);
                }
            }

            {
                var i1 = new IntEnum[11]
                {
                    IntEnum.ienum1,
                    IntEnum.ienum2,
                    IntEnum.ienum3,
                    IntEnum.ienum4,
                    IntEnum.ienum5,
                    IntEnum.ienum6,
                    IntEnum.ienum7,
                    IntEnum.ienum8,
                    IntEnum.ienum9,
                    IntEnum.ienum10,
                    IntEnum.ienum11
                };

                (IntEnum[] i3, IntEnum[] i2) = proxy.opIntSeq(i1);

                for (int i = 0; i < i1.Length; ++i)
                {
                    TestHelper.Assert(i1[i] == i2[i]);
                    TestHelper.Assert(i1[i] == i3[i]);
                }
            }

            {
                var s1 = new SimpleEnum[3]
                {
                    SimpleEnum.red,
                    SimpleEnum.green,
                    SimpleEnum.blue
                };

                (SimpleEnum[] s3, SimpleEnum[] s2) = proxy.opSimpleSeq(s1);

                for (int i = 0; i < s1.Length; ++i)
                {
                    TestHelper.Assert(s1[i] == s2[i]);
                    TestHelper.Assert(s1[i] == s3[i]);
                }
            }

            output.WriteLine("ok");
            return(proxy);
        }
 public static extern byte GetEnumUnderlyingValue(ByteEnum b);
Ejemplo n.º 27
0
 public static ByteFlags Test(ByteEnum b, ref IntEnum i, out ShortEnum s)
 {
     s = b == ByteEnum.Max ? ShortEnum.Max : ShortEnum.Min;
     i = i == IntEnum.Min ? IntEnum.Max : IntEnum.Min;
     return(ByteFlags.Bit5 | ByteFlags.Bit1);
 }
Ejemplo n.º 28
0
 private sbyte Enum1ToSByte(ByteEnum value)
 {
     return((sbyte)value);
 }
Ejemplo n.º 29
0
 public AllSupported(Int32 arraySize)
 {
   enum16list = new List<Int16Enum>(arraySize);
   aSnake = new PersistenceByInterfaceSnake("Curly", 1, true, 58);
   jaggedArray[0] = new int[] { 1, 3, 5, 7, 9 };
   jaggedArray[1] = new int[] { 0, 2, 4, 6 };
   jaggedArray[2] = new int[] { 11, 22 };
   nullabledateTime = null;
   m_nullableByte = null;
   m_enumByte = ByteEnum.b;
   m_enumInt16 = Int16Enum.c;
   m_enumInt32 = Int32Enum.f;
   m_enumInt64 = Int64Enum.ff;
   byteArray = new byte[arraySize];
   charArray = new char[arraySize];
   uint16Array = new UInt16[arraySize];
   uint32Array = new UInt32[arraySize];
   uint64Array = new UInt64[arraySize];
   int16Array = new Int16[arraySize];
   int32Array = new Int32[arraySize];
   int64Array = new Int64[arraySize];
   floatArray = new float[arraySize];
   doubleArray = new double[arraySize];
   dateTimeArray = new DateTime[arraySize];
   oidArray = new Oid[arraySize];
   nullablebyteArray = new byte?[arraySize];
   nullablecharArray = new char?[arraySize];
   nullableuint16Array = new UInt16?[arraySize];
   nullableuint32Array = new UInt32?[arraySize];
   nullableuint64Array = new UInt64?[arraySize];
   nullableint16Array = new Int16?[arraySize];
   nullableint32Array = new Int32?[arraySize];
   nullableint64Array = new Int64?[arraySize];
   nullablefloatArray = new float?[arraySize];
   nullabledoubleArray = new double?[arraySize];
   nullableDateTimeArray = new DateTime?[arraySize];
   nullableDecimalArray = new Decimal?[arraySize];
   nullableGuidArray = new Guid?[arraySize];
   nullableOidArray = new Oid?[arraySize];
   listByte = new List<byte>(arraySize); // just samples of what Key can be
   personList = new List<Person>(arraySize);
   petListOidShort = new List<Pet>(arraySize);
   petListLongOid = new List<Pet>(arraySize);
   petList2 = new ArrayList(arraySize);
   int32List = new List<Int32>(arraySize);
   uint32List = new List<UInt32>(arraySize);
   uint64List = new List<ulong>(arraySize);
   oidList = new List<Oid>(arraySize);
   nullableoidList = new List<Oid?>(arraySize);
   personHashSet = new VelocityDbHashSet<Person>();
   person = new Person();
   timeSpan = new TimeSpan(1, 0, 0);
   personArrayOidShort = new Person[arraySize];
   if (arraySize > 1)
     personArrayOidShort[1] = new Person();
   personArrayOidShort[0] = null;
   personListShort = new List<Person>(arraySize);
   personListShort.Add(null);
   personListShort.Add(null);
   personListShort.Add(new Person());
   aPet = new Cat("Boze", 5);
   petListOidShort.Add(aPet);
   petListOidShort.Add(null);
   petListLongOid.Add(aPet);
   petList2.Add(aPet);
   uint32List.Add(5555);
   int32List.Add(-66666);
   uint64List.Add(8989898988989);
   doubleArray[0] = 0.2323232323232;
   aSlot = new Slot();
   aSlot.value = new Person();
   m_slots = new Slot[5];
   enum16list.Add(m_enumInt16);
   nullableoidList.Add(new Oid((ulong)4444));
   nullableoidList.Add(null);
   nullableoidList.Add(new Oid((ulong)8888));
   if (arraySize > 0)
   {
     oidArray[0] = new Oid((ulong)99999);
     nullableOidArray[0] = new Oid((ulong)99999);
     nullableint32Array[0] = 5;
   }
   if (arraySize > 2)
   {
     oidArray[2] = new Oid((ulong)66666);
     nullableOidArray[2] = new Oid((ulong)66666);
     nullableint32Array[2] = 6;
   }
   for (int i = 0; i < 5; i++)
   {
     m_slots[i].hashCode = i;
     m_slots[i].value = new Person();
     m_slots[i].next = i + 1;
   }
 }
Ejemplo n.º 30
0
 private long Enum1ToLong(ByteEnum value)
 {
     return((long)value);
 }
Ejemplo n.º 31
0
 public static ByteEnum PassthroughByteEnum(ByteEnum value)
 {
     return(value);
 }
Ejemplo n.º 32
0
 public AllSupported(Int32 arraySize, SessionBase session)
 {
     _uint64EnumArray = new UInt64Enum[arraySize];
     if (arraySize > 1)
     {
         _uint64EnumArray[1] = UInt64Enum.dd;
     }
     enum16list         = new List <Int16Enum>(arraySize);
     aSnake             = new PersistenceByInterfaceSnake("Curly", 1, true, 58);
     jaggedArray[0]     = new int[] { 1, 3, 5, 7, 9 };
     jaggedArray[1]     = new int[] { 0, 2, 4, 6 };
     jaggedArray[2]     = new int[] { 11, 22 };
     m_nullabledateTime = null;
     m_nullableByte     = null;
     m_enumByte         = ByteEnum.b;
     m_enumInt16        = Int16Enum.c;
     m_enumInt32        = Int32Enum.f;
     m_enumInt64        = Int64Enum.ff;
     m_enumUInt64       = UInt64Enum.ff;
     ListEnumUInt64     = new List <UInt64Enum>();
     ListEnumUInt64.Add(m_enumUInt64);
     ListEnumUInt64Nullable = new List <UInt64Enum?>();
     ListEnumUInt64Nullable.Add(null);
     ListEnumUInt64Nullable.Add(m_enumUInt64);
     m_objectArray          = new object[arraySize];
     m_objectInterfaceArray = new ISomeStuff[arraySize];
     byteArray             = new byte[arraySize];
     charArray             = new char[arraySize];
     m_weakRefArray        = new WeakIOptimizedPersistableReference <IOptimizedPersistable> [arraySize];
     uint16Array           = new UInt16[arraySize];
     uint32Array           = new UInt32[arraySize];
     uint64Array           = new UInt64[arraySize];
     int16Array            = new Int16[arraySize];
     int32Array            = new Int32[arraySize];
     int64Array            = new Int64[arraySize];
     floatArray            = new float[arraySize];
     doubleArray           = new double[arraySize];
     dateTimeArray         = new DateTime[arraySize];
     oidArray              = new Oid[arraySize];
     nullablebyteArray     = new byte?[arraySize];
     nullablecharArray     = new char?[arraySize];
     nullableuint16Array   = new UInt16?[arraySize];
     nullableuint32Array   = new UInt32?[arraySize];
     nullableuint64Array   = new UInt64?[arraySize];
     nullableint16Array    = new Int16?[arraySize];
     nullableint32Array    = new Int32?[arraySize];
     nullableint64Array    = new Int64?[arraySize];
     nullablefloatArray    = new float?[arraySize];
     nullabledoubleArray   = new double?[arraySize];
     nullableDateTimeArray = new DateTime?[arraySize];
     nullableDecimalArray  = new Decimal?[arraySize];
     nullableGuidArray     = new Guid?[arraySize];
     nullableOidArray      = new Oid?[arraySize];
     listByte              = new List <byte>(arraySize); // just samples of what Key can be
     personList            = new List <Person>(arraySize);
     m_petListOidShort     = new List <Pet>(arraySize);
     petListLongOid        = new List <Pet>(arraySize);
     petList2              = new ArrayList(arraySize);
     int32List             = new List <Int32>(arraySize);
     uint32List            = new List <UInt32>(arraySize);
     uint64List            = new List <ulong>(arraySize);
     oidList         = new List <Oid>(arraySize);
     nullableoidList = new List <Oid?>(arraySize);
     personHashSet   = new VelocityDbHashSet <Person>();
     person          = new Person();
     personHashSet.Add(person);
     //session.Persist(personHashSet);
     session.Persist(person);
     _weakRefToPerson    = new WeakReferencedConnection <Person>(person);
     timeSpan            = new TimeSpan(1, 0, 0);
     personArrayOidShort = new Person[arraySize];
     if (arraySize > 1)
     {
         personArrayOidShort[1] = new Person();
     }
     personArrayOidShort[0] = null;
     personListShort        = new List <Person>(arraySize);
     personListShort.Add(null);
     personListShort.Add(null);
     personListShort.Add(new Person());
     aPet = new Cat("Boze", 5);
     m_petListOidShort.Add(aPet);
     m_petListOidShort.Add(null);
     aPet = new Cat("Fendy", 4); // create a new cat so that first cat is created within same database as owner (OidShort)
     petListLongOid.Add(aPet);
     petList2.Add(aPet);
     uint32List.Add(5555);
     int32List.Add(-66666);
     uint64List.Add(8989898988989);
     doubleArray[0] = 0.2323232323232;
     aSlot          = new Slot();
     aSlot.value    = new Person();
     m_slots        = new Slot[5];
     enum16list.Add(m_enumInt16);
     nullableoidList.Add(new Oid((ulong)4444));
     nullableoidList.Add(null);
     nullableoidList.Add(new Oid((ulong)8888));
     if (arraySize > 0)
     {
         oidArray[0]           = new Oid((ulong)99999);
         nullableOidArray[0]   = new Oid((ulong)99999);
         nullableint32Array[0] = 5;
     }
     if (arraySize > 2)
     {
         m_objectArray[1]          = this;
         m_objectInterfaceArray[2] = this;
         oidArray[2]           = new Oid((ulong)66666);
         nullableOidArray[2]   = new Oid((ulong)66666);
         nullableint32Array[2] = 6;
     }
     for (int i = 0; i < 5; i++)
     {
         m_slots[i].hashCode = i;
         m_slots[i].value    = new Person();
         m_slots[i].next     = i + 1;
     }
 }
 public void ByteEnumsAreReadCorrectly(ByteEnum enumValue, ByteOrder byteOrder)
 {
     var constructStream = new ConstructReaderStream(DataStream.Create((byte)enumValue));
     var result = constructStream.ReadEnum(typeof(ByteEnum), byteOrder);
     Assert.AreEqual(enumValue, result);
 }
Ejemplo n.º 34
0
    public static TestIntfPrx allTests(Ice.Communicator communicator)
#endif
    {
        string sref = "test:default -p 12010";
        Ice.ObjectPrx obj = communicator.stringToProxy(sref);
        test(obj != null);
        TestIntfPrx proxy = TestIntfPrxHelper.uncheckedCast(obj);
        test(proxy != null);

        Console.Out.Write("testing enum values... ");
        Console.Out.Flush();

        test((int)ByteEnum.benum1 == 0);
        test((int)ByteEnum.benum2 == 1);
        test((int)ByteEnum.benum3 == ByteConst1.value);
        test((int)ByteEnum.benum4 == ByteConst1.value + 1);
        test((int)ByteEnum.benum5 == ShortConst1.value);
        test((int)ByteEnum.benum6 == ShortConst1.value + 1);
        test((int)ByteEnum.benum7 == IntConst1.value);
        test((int)ByteEnum.benum8 == IntConst1.value + 1);
        test((int)ByteEnum.benum9 == LongConst1.value);
        test((int)ByteEnum.benum10 == LongConst1.value + 1);
        test((int)ByteEnum.benum11 == ByteConst2.value);

        test((int)ShortEnum.senum1 == 3);
        test((int)ShortEnum.senum2 == 4);
        test((int)ShortEnum.senum3 == ByteConst1.value);
        test((int)ShortEnum.senum4 == ByteConst1.value + 1);
        test((int)ShortEnum.senum5 == ShortConst1.value);
        test((int)ShortEnum.senum6 == ShortConst1.value + 1);
        test((int)ShortEnum.senum7 == IntConst1.value);
        test((int)ShortEnum.senum8 == IntConst1.value + 1);
        test((int)ShortEnum.senum9 == LongConst1.value);
        test((int)ShortEnum.senum10 == LongConst1.value + 1);
        test((int)ShortEnum.senum11 == ShortConst2.value);

        test((int)IntEnum.ienum1 == 0);
        test((int)IntEnum.ienum2 == 1);
        test((int)IntEnum.ienum3 == ByteConst1.value);
        test((int)IntEnum.ienum4 == ByteConst1.value + 1);
        test((int)IntEnum.ienum5 == ShortConst1.value);
        test((int)IntEnum.ienum6 == ShortConst1.value + 1);
        test((int)IntEnum.ienum7 == IntConst1.value);
        test((int)IntEnum.ienum8 == IntConst1.value + 1);
        test((int)IntEnum.ienum9 == LongConst1.value);
        test((int)IntEnum.ienum10 == LongConst1.value + 1);
        test((int)IntEnum.ienum11 == IntConst2.value);
        test((int)IntEnum.ienum12 == LongConst2.value);

        test((int)SimpleEnum.red == 0);
        test((int)SimpleEnum.green == 1);
        test((int)SimpleEnum.blue == 2);

        Console.Out.WriteLine("ok");

        Console.Out.Write("testing enum streaming... ");
        Console.Out.Flush();

        Ice.OutputStream ostr;
        byte[] bytes;

        bool encoding_1_0 = communicator.getProperties().getProperty("Ice.Default.EncodingVersion").Equals("1.0");

        ostr = new Ice.OutputStream(communicator);
        ostr.writeEnum((int)ByteEnum.benum11, (int)ByteEnum.benum11);
        bytes = ostr.finished();
        test(bytes.Length == 1); // ByteEnum should require one byte

        ostr = new Ice.OutputStream(communicator);
        ostr.writeEnum((int)ShortEnum.senum11, (int)ShortEnum.senum11);
        bytes = ostr.finished();
        test(bytes.Length == (encoding_1_0 ? 2 : 5));

        ostr = new Ice.OutputStream(communicator);
        ostr.writeEnum((int)IntEnum.ienum11, (int)IntEnum.ienum12);
        bytes = ostr.finished();
        test(bytes.Length == (encoding_1_0 ? 4 : 5));

        ostr = new Ice.OutputStream(communicator);
        ostr.writeEnum((int)SimpleEnum.blue, (int)SimpleEnum.blue);
        bytes = ostr.finished();
        test(bytes.Length == 1); // SimpleEnum should require one byte

        Console.Out.WriteLine("ok");

        Console.Out.Write("testing enum operations... ");
        Console.Out.Flush();

        ByteEnum byteEnum;
        test(proxy.opByte(ByteEnum.benum1, out byteEnum) == ByteEnum.benum1);
        test(byteEnum == ByteEnum.benum1);
        test(proxy.opByte(ByteEnum.benum11, out byteEnum) == ByteEnum.benum11);
        test(byteEnum == ByteEnum.benum11);

        ShortEnum shortEnum;
        test(proxy.opShort(ShortEnum.senum1, out shortEnum) == ShortEnum.senum1);
        test(shortEnum == ShortEnum.senum1);
        test(proxy.opShort(ShortEnum.senum11, out shortEnum) == ShortEnum.senum11);
        test(shortEnum == ShortEnum.senum11);

        IntEnum intEnum;
        test(proxy.opInt(IntEnum.ienum1, out intEnum) == IntEnum.ienum1);
        test(intEnum == IntEnum.ienum1);
        test(proxy.opInt(IntEnum.ienum11, out intEnum) == IntEnum.ienum11);
        test(intEnum == IntEnum.ienum11);
        test(proxy.opInt(IntEnum.ienum12, out intEnum) == IntEnum.ienum12);
        test(intEnum == IntEnum.ienum12);

        SimpleEnum s;
        test(proxy.opSimple(SimpleEnum.green, out s) == SimpleEnum.green);
        test(s == SimpleEnum.green);

        Console.Out.WriteLine("ok");

        Console.Out.Write("testing enum sequences operations... ");
        Console.Out.Flush();

        {
            ByteEnum[] b1 = new ByteEnum[11]
                    { ByteEnum.benum1, ByteEnum.benum2, ByteEnum.benum3, ByteEnum.benum4, ByteEnum.benum5,
                      ByteEnum.benum6, ByteEnum.benum7, ByteEnum.benum8, ByteEnum.benum9, ByteEnum.benum10,
                      ByteEnum.benum11};

            ByteEnum[] b2;
            ByteEnum[] b3 = proxy.opByteSeq(b1, out b2);

            for(int i = 0; i < b1.Length; ++i)
            {
                test(b1[i] == b2[i]);
                test(b1[i] == b3[i]);
            }
        }

        {
            ShortEnum[] s1 = new ShortEnum[11]
                    { ShortEnum.senum1, ShortEnum.senum2, ShortEnum.senum3, ShortEnum.senum4, ShortEnum.senum5,
                      ShortEnum.senum6, ShortEnum.senum7, ShortEnum.senum8, ShortEnum.senum9, ShortEnum.senum10,
                      ShortEnum.senum11};

            ShortEnum[] s2;
            ShortEnum[] s3 = proxy.opShortSeq(s1, out s2);

            for(int i = 0; i < s1.Length; ++i)
            {
                test(s1[i] == s2[i]);
                test(s1[i] == s3[i]);
            }
        }

        {
            IntEnum[] i1 = new IntEnum[11]
                    { IntEnum.ienum1, IntEnum.ienum2, IntEnum.ienum3, IntEnum.ienum4, IntEnum.ienum5,
                      IntEnum.ienum6, IntEnum.ienum7, IntEnum.ienum8, IntEnum.ienum9, IntEnum.ienum10,
                      IntEnum.ienum11};

            IntEnum[] i2;
            IntEnum[] i3 = proxy.opIntSeq(i1, out i2);

            for(int i = 0; i < i1.Length; ++i)
            {
                test(i1[i] == i2[i]);
                test(i1[i] == i3[i]);
            }
        }

        {
            SimpleEnum[] s1 = new SimpleEnum[3]
                    { SimpleEnum.red, SimpleEnum.green, SimpleEnum.blue };

            SimpleEnum[] s2;
            SimpleEnum[] s3 = proxy.opSimpleSeq(s1, out s2);

            for(int i = 0; i < s1.Length; ++i)
            {
                test(s1[i] == s2[i]);
                test(s1[i] == s3[i]);
            }
        }

        Console.Out.WriteLine("ok");
#if SILVERLIGHT
        proxy.shutdown();
#else
        return proxy;
#endif
    }
Ejemplo n.º 35
0
 public AllSupported(Int32 arraySize)
 {
     enum16list            = new List <Int16Enum>(arraySize);
     aSnake                = new PersistenceByInterfaceSnake("Curly", 1, true, 58);
     jaggedArray[0]        = new int[] { 1, 3, 5, 7, 9 };
     jaggedArray[1]        = new int[] { 0, 2, 4, 6 };
     jaggedArray[2]        = new int[] { 11, 22 };
     nullabledateTime      = null;
     m_nullableByte        = null;
     m_enumByte            = ByteEnum.b;
     m_enumInt16           = Int16Enum.c;
     m_enumInt32           = Int32Enum.f;
     m_enumInt64           = Int64Enum.ff;
     byteArray             = new byte[arraySize];
     charArray             = new char[arraySize];
     uint16Array           = new UInt16[arraySize];
     uint32Array           = new UInt32[arraySize];
     uint64Array           = new UInt64[arraySize];
     int16Array            = new Int16[arraySize];
     int32Array            = new Int32[arraySize];
     int64Array            = new Int64[arraySize];
     floatArray            = new float[arraySize];
     doubleArray           = new double[arraySize];
     dateTimeArray         = new DateTime[arraySize];
     oidArray              = new Oid[arraySize];
     nullablebyteArray     = new byte?[arraySize];
     nullablecharArray     = new char?[arraySize];
     nullableuint16Array   = new UInt16?[arraySize];
     nullableuint32Array   = new UInt32?[arraySize];
     nullableuint64Array   = new UInt64?[arraySize];
     nullableint16Array    = new Int16?[arraySize];
     nullableint32Array    = new Int32?[arraySize];
     nullableint64Array    = new Int64?[arraySize];
     nullablefloatArray    = new float?[arraySize];
     nullabledoubleArray   = new double?[arraySize];
     nullableDateTimeArray = new DateTime?[arraySize];
     nullableDecimalArray  = new Decimal?[arraySize];
     nullableGuidArray     = new Guid?[arraySize];
     nullableOidArray      = new Oid?[arraySize];
     listByte              = new List <byte>(arraySize); // just samples of what Key can be
     personList            = new List <Person>(arraySize);
     petListOidShort       = new List <Pet>(arraySize);
     petListLongOid        = new List <Pet>(arraySize);
     petList2              = new ArrayList(arraySize);
     int32List             = new List <Int32>(arraySize);
     uint32List            = new List <UInt32>(arraySize);
     uint64List            = new List <ulong>(arraySize);
     oidList               = new List <Oid>(arraySize);
     nullableoidList       = new List <Oid?>(arraySize);
     personHashSet         = new VelocityDbHashSet <Person>();
     person                = new Person();
     timeSpan              = new TimeSpan(1, 0, 0);
     personArrayOidShort   = new Person[arraySize];
     if (arraySize > 1)
     {
         personArrayOidShort[1] = new Person();
     }
     personArrayOidShort[0] = null;
     personListShort        = new List <Person>(arraySize);
     personListShort.Add(null);
     personListShort.Add(null);
     personListShort.Add(new Person());
     aPet = new Cat("Boze", 5);
     petListOidShort.Add(aPet);
     petListOidShort.Add(null);
     petListLongOid.Add(aPet);
     petList2.Add(aPet);
     uint32List.Add(5555);
     int32List.Add(-66666);
     uint64List.Add(8989898988989);
     doubleArray[0] = 0.2323232323232;
     aSlot          = new Slot();
     aSlot.value    = new Person();
     m_slots        = new Slot[5];
     enum16list.Add(m_enumInt16);
     nullableoidList.Add(new Oid((ulong)4444));
     nullableoidList.Add(null);
     nullableoidList.Add(new Oid((ulong)8888));
     if (arraySize > 0)
     {
         oidArray[0]           = new Oid((ulong)99999);
         nullableOidArray[0]   = new Oid((ulong)99999);
         nullableint32Array[0] = 5;
     }
     if (arraySize > 2)
     {
         oidArray[2]           = new Oid((ulong)66666);
         nullableOidArray[2]   = new Oid((ulong)66666);
         nullableint32Array[2] = 6;
     }
     for (int i = 0; i < 5; i++)
     {
         m_slots[i].hashCode = i;
         m_slots[i].value    = new Person();
         m_slots[i].next     = i + 1;
     }
 }