Пример #1
0
        public static IMyClassPrx Run(TestHelper helper)
        {
            Communicator?communicator = helper.Communicator;

            TestHelper.Assert(communicator != null);
            bool        ice1   = helper.Protocol == Protocol.Ice1;
            var         cl     = IMyClassPrx.Parse(helper.GetTestProxy("test", 0), communicator);
            IMyClassPrx oneway = cl.Clone(oneway: true);

            System.IO.TextWriter output = helper.Output;
            output.Write("testing InvokeAsync... ");
            output.Flush();

            {
                var request = OutgoingRequestFrame.WithEmptyArgs(oneway, "opOneway", idempotent: false);
                IncomingResponseFrame response;
                try
                {
                    response = oneway.InvokeAsync(request, oneway: true).Result;
                }
                catch
                {
                    TestHelper.Assert(false);
                }

                request = OutgoingRequestFrame.WithArgs(cl,
                                                        "opString",
                                                        idempotent: false,
                                                        compress: false,
                                                        format: default,
Пример #2
0
        public static IMyClassPrx Run(TestHelper helper)
        {
            Communicator?communicator = helper.Communicator;

            TestHelper.Assert(communicator != null);
            bool        ice1   = helper.Protocol == Protocol.Ice1;
            var         cl     = IMyClassPrx.Parse(helper.GetTestProxy("test", 0), communicator);
            IMyClassPrx oneway = cl.Clone(oneway: true);

            System.IO.TextWriter output = helper.Output;
            output.Write("testing Invoke... ");
            output.Flush();

            {
                var request = OutgoingRequestFrame.WithEmptyArgs(oneway, "opOneway", idempotent: false);

                // Whether the proxy is oneway or not does not matter for Invoke's oneway parameter.

                IncomingResponseFrame response = cl.Invoke(request, oneway: true);
                if (ice1)
                {
                    TestHelper.Assert(response.ResultType == ResultType.Success);
                }

                request  = OutgoingRequestFrame.WithEmptyArgs(oneway, "opOneway", idempotent: false);
                response = cl.Invoke(request, oneway: false);
                if (ice1)
                {
                    TestHelper.Assert(response.ResultType == ResultType.Failure);
                }

                request  = OutgoingRequestFrame.WithEmptyArgs(oneway, "opOneway", idempotent: false);
                response = oneway.Invoke(request, oneway: true);
                if (ice1)
                {
                    TestHelper.Assert(response.ResultType == ResultType.Success);
                }

                request  = OutgoingRequestFrame.WithEmptyArgs(oneway, "opOneway", idempotent: false);
                response = oneway.Invoke(request, oneway: false);
                if (ice1)
                {
                    TestHelper.Assert(response.ResultType == ResultType.Failure);
                }

                request = OutgoingRequestFrame.WithArgs(cl,
                                                        "opString",
                                                        idempotent: false,
                                                        compress: false,
                                                        format: default,
Пример #3
0
        public static async Task RunAsync(TestHelper helper)
        {
            Communicator communicator = helper.Communicator;

            bool        ice1   = helper.Protocol == Protocol.Ice1;
            var         cl     = IMyClassPrx.Parse(helper.GetTestProxy("test", 0), communicator);
            IMyClassPrx oneway = cl.Clone(oneway: true);

            System.IO.TextWriter output = helper.Output;
            output.Write("testing InvokeAsync... ");
            output.Flush();

            {
                using var request = OutgoingRequestFrame.WithEmptyArgs(oneway, "opOneway", idempotent: false);

                try
                {
                    using IncomingResponseFrame response = oneway.InvokeAsync(request, oneway: true).Result;
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }

            {
                using var request = OutgoingRequestFrame.WithArgs(cl,
                                                                  "opString",
                                                                  idempotent: false,
                                                                  compress: false,
                                                                  format: default,
                                                                  context: null,
                                                                  TestString,
                                                                  OutputStream.IceWriterFromString);

                using IncomingResponseFrame response = cl.InvokeAsync(request).Result;
                (string s1, string s2) = response.ReadReturnValue(cl, istr =>
                {
                    string s1 = istr.ReadString();
                    string s2 = istr.ReadString();
                    return(s1, s2);
                });
                TestHelper.Assert(s1.Equals(TestString));
                TestHelper.Assert(s2.Equals(TestString));
            }

            {
                using var request = OutgoingRequestFrame.WithEmptyArgs(cl, "opException", idempotent: false);
                using IncomingResponseFrame response = cl.InvokeAsync(request).Result;

                try
                {
                    response.ReadVoidReturnValue(cl);
                    TestHelper.Assert(false);
                }
                catch (MyException)
                {
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }

            output.WriteLine("ok");
            await cl.ShutdownAsync();
        }