Exemplo n.º 1
0
    public void relayKnownPreservedAsKnownPreserved(IRelayPrx r, Current current)
    {
        IRelayPrx p = current.Connection.CreateProxy(r.Identity, IRelayPrx.Factory);

        p.knownPreservedAsKnownPreserved();
        test(false);
    }
Exemplo n.º 2
0
    public void relayUnknownPreservedAsKnownPreserved(IRelayPrx r, Ice.Current current)
    {
        IRelayPrx p = IRelayPrx.UncheckedCast(current.Connection.createProxy(r.Identity));

        p.unknownPreservedAsKnownPreserved();
        test(false);
    }
Exemplo n.º 3
0
    relayKnownPreservedAsKnownPreservedAsync(IRelayPrx r, Ice.Current current)
    {
        IRelayPrx p = current.Connection.CreateProxy(r.Identity, IRelayPrx.Factory);

        p.knownPreservedAsKnownPreserved();
        test(false);
        return(new ValueTask(Task.CompletedTask));
    }
Exemplo n.º 4
0
Arquivo: TestAMDI.cs Projeto: yzun/ice
    relayKnownPreservedAsKnownPreservedAsync(IRelayPrx r, Ice.Current current)
    {
        IRelayPrx p = current.Connection.CreateProxy(r.Identity, IRelayPrx.Factory);

        p.knownPreservedAsKnownPreserved();
        test(false);
        return(null);
    }
Exemplo n.º 5
0
    relayUnknownPreservedAsBaseAsync(IRelayPrx r, Ice.Current current)
    {
        IRelayPrx p = IRelayPrx.UncheckedCast(current.Connection.createProxy(r.Identity));

        p.unknownPreservedAsBase();
        test(false);
        return(null);
    }
Exemplo n.º 6
0
        public void RelayUnknownPreservedAsBase(IRelayPrx?r, Current current, CancellationToken cancel)
        {
            TestHelper.Assert(r != null);
            IRelayPrx p = r.Clone(fixedConnection: current.Connection);

            try
            {
                p.UnknownPreservedAsBase(cancel: cancel);
            }
            catch (RemoteException ex)
            {
                TestHelper.Assert(ex.ConvertToUnhandled);
                ex.ConvertToUnhandled = false;
                throw;
            }
            TestHelper.Assert(false);
        }
Exemplo n.º 7
0
    public void relayKnownPreservedAsKnownPreserved(IRelayPrx?r, Current current)
    {
        Debug.Assert(r != null);
        IRelayPrx p = current.Connection.CreateProxy(r.Identity, IRelayPrx.Factory);

        try
        {
            p.knownPreservedAsKnownPreserved();
        }
        catch (RemoteException ex)
        {
            test(ex.ConvertToUnhandled);
            ex.ConvertToUnhandled = false;
            throw;
        }
        test(false);
    }
Exemplo n.º 8
0
    public void relayKnownPreservedAsBase(IRelayPrx?r, Current current)
    {
        TestHelper.Assert(r != null);
        IRelayPrx p = r.Clone(fixedConnection: current.Connection);

        try
        {
            p.knownPreservedAsBase();
        }
        catch (RemoteException ex)
        {
            TestHelper.Assert(ex.ConvertToUnhandled);
            ex.ConvertToUnhandled = false;
            throw;
        }
        TestHelper.Assert(false);
    }
Exemplo n.º 9
0
    public void relayClientPrivateException(IRelayPrx?r, Current current)
    {
        TestHelper.Assert(r != null);
        IRelayPrx p = r.Clone(fixedConnection: current.Connection);

        try
        {
            p.clientPrivateException();
        }
        catch (RemoteException ex)
        {
            TestHelper.Assert(ex.ConvertToUnhandled);
            ex.ConvertToUnhandled = false;
            throw;
        }
        TestHelper.Assert(false);
    }
Exemplo n.º 10
0
    public void relayUnknownPreservedAsKnownPreserved(IRelayPrx?r, Ice.Current current)
    {
        TestHelper.Assert(r != null);
        IRelayPrx p = current.Connection !.CreateProxy(r.Identity, IRelayPrx.Factory);

        try
        {
            p.unknownPreservedAsKnownPreserved();
        }
        catch (RemoteException ex)
        {
            TestHelper.Assert(ex.ConvertToUnhandled);
            ex.ConvertToUnhandled = false;
            throw;
        }
        TestHelper.Assert(false);
    }
Exemplo n.º 11
0
    public void relayClientPrivateException(IRelayPrx?r, Current current)
    {
        TestHelper.Assert(r != null);
        IRelayPrx p = current.Connection !.CreateProxy(r.Identity, IRelayPrx.Factory);

        try
        {
            p.clientPrivateException();
        }
        catch (RemoteException ex)
        {
            TestHelper.Assert(ex.ConvertToUnhandled);
            ex.ConvertToUnhandled = false;
            throw;
        }
        TestHelper.Assert(false);
    }
Exemplo n.º 12
0
        public async ValueTask RelayKnownPreservedAsKnownPreservedAsync(IRelayPrx?r, Current current, CancellationToken cancel)
        {
            TestHelper.Assert(r != null);
            IRelayPrx p = r.Clone(fixedConnection: current.Connection);

            try
            {
                await p.KnownPreservedAsKnownPreservedAsync(cancel : cancel);
            }
            catch (RemoteException ex)
            {
                TestHelper.Assert(ex.ConvertToUnhandled);
                ex.ConvertToUnhandled = false;
                throw;
            }
            TestHelper.Assert(false);
        }
Exemplo n.º 13
0
        public async ValueTask RelayClientPrivateExceptionAsync(IRelayPrx?r, Current current)
        {
            TestHelper.Assert(r != null);
            IRelayPrx p = r.Clone(fixedConnection: current.Connection);

            try
            {
                await p.ClientPrivateExceptionAsync();
            }
            catch (RemoteException ex)
            {
                TestHelper.Assert(ex.ConvertToUnhandled);
                ex.ConvertToUnhandled = false;
                throw;
            }
            TestHelper.Assert(false);
        }
Exemplo n.º 14
0
    relayKnownPreservedAsKnownPreservedAsync(IRelayPrx?r, Current current)
    {
        TestHelper.Assert(r != null);
        IRelayPrx p = r.Clone(fixedConnection: current.Connection);

        try
        {
            p.knownPreservedAsKnownPreserved();
        }
        catch (RemoteException ex)
        {
            TestHelper.Assert(ex.ConvertToUnhandled);
            ex.ConvertToUnhandled = false;
            throw;
        }
        TestHelper.Assert(false);
        return(new ValueTask(Task.CompletedTask));
    }
Exemplo n.º 15
0
    relayKnownPreservedAsBaseAsync(IRelayPrx?r, Ice.Current current)
    {
        Debug.Assert(r != null);
        IRelayPrx p = current.Connection.CreateProxy(r.Identity, IRelayPrx.Factory);

        try
        {
            p.knownPreservedAsBase();
        }
        catch (RemoteException ex)
        {
            test(ex.ConvertToUnhandled);
            ex.ConvertToUnhandled = false;
            throw;
        }
        test(false);
        return(new ValueTask(Task.CompletedTask));
    }
Exemplo n.º 16
0
    public ValueTask relayClientPrivateExceptionAsync(IRelayPrx?r, Current current)
    {
        TestHelper.Assert(r != null);
        IRelayPrx p = current.Connection !.CreateProxy(r.Identity, IRelayPrx.Factory);

        try
        {
            p.clientPrivateException();
        }
        catch (RemoteException ex)
        {
            TestHelper.Assert(ex.ConvertToUnhandled);
            ex.ConvertToUnhandled = false;
            throw;
        }
        TestHelper.Assert(false);
        return(new ValueTask(Task.CompletedTask));
    }
Exemplo n.º 17
0
        public static ITestIntfPrx allTests(TestHelper helper)
        {
            Communicator?communicator = helper.Communicator();

            TestHelper.Assert(communicator != null);
            var output = helper.GetWriter();

            output.Write("testing stringToProxy... ");
            output.Flush();
            ITestIntfPrx testPrx = ITestIntfPrx.Parse($"Test:{helper.GetTestEndpoint(0)} -t 2000", communicator);

            output.WriteLine("ok");

            output.Write("base... ");
            output.Flush();
            {
                try
                {
                    testPrx.baseAsBase();
                    TestHelper.Assert(false);
                }
                catch (Base b)
                {
                    TestHelper.Assert(b.b.Equals("Base.b"));
                    TestHelper.Assert(b.GetType().FullName !.Equals("ZeroC.Ice.Test.Slicing.Exceptions.Base"));
                }
                catch (Exception)
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("base (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.baseAsBaseAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (Base b)
                    {
                        TestHelper.Assert(b.b.Equals("Base.b"));
                        TestHelper.Assert(b.GetType().Name.Equals("Base"));
                    }
                    catch (Exception)
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown derived... ");
            output.Flush();
            {
                try
                {
                    testPrx.unknownDerivedAsBase();
                    TestHelper.Assert(false);
                }
                catch (Base b)
                {
                    TestHelper.Assert(b.b.Equals("UnknownDerived.b"));
                    TestHelper.Assert(b.GetType().FullName !.Equals("ZeroC.Ice.Test.Slicing.Exceptions.Base"));
                }
                catch (System.Exception)
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown derived (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.unknownDerivedAsBaseAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (Base b)
                    {
                        TestHelper.Assert(b.b.Equals("UnknownDerived.b"));
                        TestHelper.Assert(b.GetType().Name.Equals("Base"));
                    }
                    catch (Exception)
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known derived as base... ");
            output.Flush();
            {
                try
                {
                    testPrx.knownDerivedAsBase();
                    TestHelper.Assert(false);
                }
                catch (KnownDerived k)
                {
                    TestHelper.Assert(k.b.Equals("KnownDerived.b"));
                    TestHelper.Assert(k.kd.Equals("KnownDerived.kd"));
                    TestHelper.Assert(k.GetType().FullName !.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownDerived"));
                }
                catch (System.Exception)
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known derived as base (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.knownDerivedAsBaseAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownDerived k)
                    {
                        TestHelper.Assert(k.b.Equals("KnownDerived.b"));
                        TestHelper.Assert(k.kd.Equals("KnownDerived.kd"));
                        TestHelper.Assert(k.GetType().Name.Equals("KnownDerived"));
                    }
                    catch (Exception)
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known derived as derived... ");
            output.Flush();
            {
                try
                {
                    testPrx.knownDerivedAsKnownDerived();
                    TestHelper.Assert(false);
                }
                catch (KnownDerived k)
                {
                    TestHelper.Assert(k.b.Equals("KnownDerived.b"));
                    TestHelper.Assert(k.kd.Equals("KnownDerived.kd"));
                    TestHelper.Assert(k.GetType().FullName !.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownDerived"));
                }
                catch (System.Exception)
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known derived as derived (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.knownDerivedAsKnownDerivedAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownDerived k)
                    {
                        TestHelper.Assert(k.b.Equals("KnownDerived.b"));
                        TestHelper.Assert(k.kd.Equals("KnownDerived.kd"));
                        TestHelper.Assert(k.GetType().Name.Equals("KnownDerived"));
                    }
                    catch (Exception)
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown intermediate as base... ");
            output.Flush();
            {
                try
                {
                    testPrx.unknownIntermediateAsBase();
                    TestHelper.Assert(false);
                }
                catch (Base b)
                {
                    TestHelper.Assert(b.b.Equals("UnknownIntermediate.b"));
                    TestHelper.Assert(b.GetType().FullName !.Equals("ZeroC.Ice.Test.Slicing.Exceptions.Base"));
                }
                catch (Exception)
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown intermediate as base (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.unknownIntermediateAsBaseAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (Base b)
                    {
                        TestHelper.Assert(b.b.Equals("UnknownIntermediate.b"));
                        TestHelper.Assert(b.GetType().Name.Equals("Base"));
                    }
                    catch (Exception)
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of known intermediate as base... ");
            output.Flush();
            {
                try
                {
                    testPrx.knownIntermediateAsBase();
                    TestHelper.Assert(false);
                }
                catch (KnownIntermediate ki)
                {
                    TestHelper.Assert(ki.b.Equals("KnownIntermediate.b"));
                    TestHelper.Assert(ki.ki.Equals("KnownIntermediate.ki"));
                    TestHelper.Assert(ki.GetType().FullName !.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownIntermediate"));
                }
                catch (Exception)
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of known intermediate as base (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.knownIntermediateAsBaseAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownIntermediate ki)
                    {
                        TestHelper.Assert(ki.b.Equals("KnownIntermediate.b"));
                        TestHelper.Assert(ki.ki.Equals("KnownIntermediate.ki"));
                        TestHelper.Assert(ki.GetType().Name.Equals("KnownIntermediate"));
                    }
                    catch (Exception)
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of known most derived as base... ");
            output.Flush();
            {
                try
                {
                    testPrx.knownMostDerivedAsBase();
                    TestHelper.Assert(false);
                }
                catch (KnownMostDerived kmd)
                {
                    TestHelper.Assert(kmd.b.Equals("KnownMostDerived.b"));
                    TestHelper.Assert(kmd.ki.Equals("KnownMostDerived.ki"));
                    TestHelper.Assert(kmd.kmd.Equals("KnownMostDerived.kmd"));
                    TestHelper.Assert(kmd.GetType().FullName !.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownMostDerived"));
                }
                catch (Exception)
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of known most derived as base (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.knownMostDerivedAsBaseAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownMostDerived kmd)
                    {
                        TestHelper.Assert(kmd.b.Equals("KnownMostDerived.b"));
                        TestHelper.Assert(kmd.ki.Equals("KnownMostDerived.ki"));
                        TestHelper.Assert(kmd.kmd.Equals("KnownMostDerived.kmd"));
                        TestHelper.Assert(kmd.GetType().Name.Equals("KnownMostDerived"));
                    }
                    catch (Exception)
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known intermediate as intermediate... ");
            output.Flush();
            {
                try
                {
                    testPrx.knownIntermediateAsKnownIntermediate();
                    TestHelper.Assert(false);
                }
                catch (KnownIntermediate ki)
                {
                    TestHelper.Assert(ki.b.Equals("KnownIntermediate.b"));
                    TestHelper.Assert(ki.ki.Equals("KnownIntermediate.ki"));
                    TestHelper.Assert(ki.GetType().FullName !.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownIntermediate"));
                }
                catch (Exception)
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known intermediate as intermediate (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.knownIntermediateAsKnownIntermediateAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownIntermediate ki)
                    {
                        TestHelper.Assert(ki.b.Equals("KnownIntermediate.b"));
                        TestHelper.Assert(ki.ki.Equals("KnownIntermediate.ki"));
                        TestHelper.Assert(ki.GetType().Name.Equals("KnownIntermediate"));
                    }
                    catch (Exception)
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known most derived as intermediate... ");
            output.Flush();
            {
                try
                {
                    testPrx.knownMostDerivedAsKnownIntermediate();
                    TestHelper.Assert(false);
                }
                catch (KnownMostDerived kmd)
                {
                    TestHelper.Assert(kmd.b.Equals("KnownMostDerived.b"));
                    TestHelper.Assert(kmd.ki.Equals("KnownMostDerived.ki"));
                    TestHelper.Assert(kmd.kmd.Equals("KnownMostDerived.kmd"));
                    TestHelper.Assert(kmd.GetType().FullName !.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownMostDerived"));
                }
                catch (Exception)
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known most derived as intermediate (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.knownMostDerivedAsKnownIntermediateAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownMostDerived kmd)
                    {
                        TestHelper.Assert(kmd.b.Equals("KnownMostDerived.b"));
                        TestHelper.Assert(kmd.ki.Equals("KnownMostDerived.ki"));
                        TestHelper.Assert(kmd.kmd.Equals("KnownMostDerived.kmd"));
                        TestHelper.Assert(kmd.GetType().Name.Equals("KnownMostDerived"));
                    }
                    catch (Exception)
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known most derived as most derived... ");
            output.Flush();
            {
                try
                {
                    testPrx.knownMostDerivedAsKnownMostDerived();
                    TestHelper.Assert(false);
                }
                catch (KnownMostDerived kmd)
                {
                    TestHelper.Assert(kmd.b.Equals("KnownMostDerived.b"));
                    TestHelper.Assert(kmd.ki.Equals("KnownMostDerived.ki"));
                    TestHelper.Assert(kmd.kmd.Equals("KnownMostDerived.kmd"));
                    TestHelper.Assert(kmd.GetType().FullName !.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownMostDerived"));
                }
                catch (Exception)
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known most derived as most derived (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.knownMostDerivedAsKnownMostDerivedAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownMostDerived kmd)
                    {
                        TestHelper.Assert(kmd.b.Equals("KnownMostDerived.b"));
                        TestHelper.Assert(kmd.ki.Equals("KnownMostDerived.ki"));
                        TestHelper.Assert(kmd.kmd.Equals("KnownMostDerived.kmd"));
                        TestHelper.Assert(kmd.GetType().Name.Equals("KnownMostDerived"));
                    }
                    catch (Exception)
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown most derived, known intermediate as base... ");
            output.Flush();
            {
                try
                {
                    testPrx.unknownMostDerived1AsBase();
                    TestHelper.Assert(false);
                }
                catch (KnownIntermediate ki)
                {
                    TestHelper.Assert(ki.b.Equals("UnknownMostDerived1.b"));
                    TestHelper.Assert(ki.ki.Equals("UnknownMostDerived1.ki"));
                    TestHelper.Assert(ki.GetType().FullName !.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownIntermediate"));
                }
                catch (Exception)
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown most derived, known intermediate as base (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.unknownMostDerived1AsBaseAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownIntermediate ki)
                    {
                        TestHelper.Assert(ki.b.Equals("UnknownMostDerived1.b"));
                        TestHelper.Assert(ki.ki.Equals("UnknownMostDerived1.ki"));
                        TestHelper.Assert(ki.GetType().Name.Equals("KnownIntermediate"));
                    }
                    catch (Exception)
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown most derived, known intermediate as intermediate... ");
            output.Flush();
            {
                try
                {
                    testPrx.unknownMostDerived1AsKnownIntermediate();
                    TestHelper.Assert(false);
                }
                catch (KnownIntermediate ki)
                {
                    TestHelper.Assert(ki.b.Equals("UnknownMostDerived1.b"));
                    TestHelper.Assert(ki.ki.Equals("UnknownMostDerived1.ki"));
                    TestHelper.Assert(ki.GetType().FullName !.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownIntermediate"));
                }
                catch (Exception)
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown most derived, known intermediate as intermediate (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.unknownMostDerived1AsKnownIntermediateAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownIntermediate ki)
                    {
                        TestHelper.Assert(ki.b.Equals("UnknownMostDerived1.b"));
                        TestHelper.Assert(ki.ki.Equals("UnknownMostDerived1.ki"));
                        TestHelper.Assert(ki.GetType().Name.Equals("KnownIntermediate"));
                    }
                    catch (Exception)
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown most derived, unknown intermediate thrown as base... ");
            output.Flush();
            {
                try
                {
                    testPrx.unknownMostDerived2AsBase();
                    TestHelper.Assert(false);
                }
                catch (Base b)
                {
                    TestHelper.Assert(b.b.Equals("UnknownMostDerived2.b"));
                    TestHelper.Assert(b.GetType().FullName !.Equals("ZeroC.Ice.Test.Slicing.Exceptions.Base"));
                }
                catch (Exception)
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown most derived, unknown intermediate thrown as base (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.unknownMostDerived2AsBaseAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (Base b)
                    {
                        TestHelper.Assert(b.b.Equals("UnknownMostDerived2.b"));
                        TestHelper.Assert(b.GetType().Name.Equals("Base"));
                    }
                    catch (Exception)
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("unknown most derived in compact format... ");
            output.Flush();
            {
                try
                {
                    testPrx.unknownMostDerived2AsBaseCompact();
                    TestHelper.Assert(false);
                }
                catch (Base)
                {
                    // Exceptions are always marshaled in sliced format; format:compact applies only to in-parameters and
                    // return values.
                }
                catch (OperationNotExistException)
                {
                }
                catch (Exception)
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("completely unknown server-private exception... ");
            output.Flush();
            {
                try
                {
                    testPrx.serverPrivateException();
                    TestHelper.Assert(false);
                }
                catch (RemoteException ex)
                {
                    SlicedData slicedData = ex.GetSlicedData() !.Value;
                    TestHelper.Assert(slicedData.Slices.Count == 1);
                    TestHelper.Assert(slicedData.Slices[0].TypeId ! == "::Slicing::Exceptions::ServerPrivateException");
                }
                catch (Exception)
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("preserved exceptions... ");
            output.Flush();
            {
                try
                {
                    testPrx.unknownPreservedAsBase();
                    TestHelper.Assert(false);
                }
                catch (Base ex)
                {
                    IReadOnlyList <SliceInfo> slices = ex.GetSlicedData() !.Value.Slices;
                    TestHelper.Assert(slices.Count == 2);
                    TestHelper.Assert(slices[1].TypeId !.Equals("::Slicing::Exceptions::SPreserved1"));
                    TestHelper.Assert(slices[0].TypeId !.Equals("::Slicing::Exceptions::SPreserved2"));
                }

                try
                {
                    testPrx.unknownPreservedAsKnownPreserved();
                    TestHelper.Assert(false);
                }
                catch (KnownPreserved ex)
                {
                    TestHelper.Assert(ex.kp.Equals("preserved"));
                    IReadOnlyList <SliceInfo> slices = ex.GetSlicedData() !.Value.Slices;
                    TestHelper.Assert(slices.Count == 2);
                    TestHelper.Assert(slices[1].TypeId !.Equals("::Slicing::Exceptions::SPreserved1"));
                    TestHelper.Assert(slices[0].TypeId !.Equals("::Slicing::Exceptions::SPreserved2"));
                }

                ObjectAdapter adapter = communicator.CreateObjectAdapter();
                IRelayPrx     relay   = adapter.AddWithUUID(new Relay(), IRelayPrx.Factory);
                adapter.Activate();
                testPrx.GetConnection().Adapter = adapter;

                try
                {
                    testPrx.relayKnownPreservedAsBase(relay);
                    TestHelper.Assert(false);
                }
                catch (KnownPreservedDerived ex)
                {
                    TestHelper.Assert(ex.b.Equals("base"));
                    TestHelper.Assert(ex.kp.Equals("preserved"));
                    TestHelper.Assert(ex.kpd.Equals("derived"));
                }
                catch (OperationNotExistException)
                {
                }
                catch (System.Exception)
                {
                    TestHelper.Assert(false);
                }

                try
                {
                    testPrx.relayKnownPreservedAsKnownPreserved(relay);
                    TestHelper.Assert(false);
                }
                catch (KnownPreservedDerived ex)
                {
                    TestHelper.Assert(ex.b.Equals("base"));
                    TestHelper.Assert(ex.kp.Equals("preserved"));
                    TestHelper.Assert(ex.kpd.Equals("derived"));
                }
                catch (OperationNotExistException)
                {
                }
                catch (System.Exception)
                {
                    TestHelper.Assert(false);
                }

                try
                {
                    testPrx.relayUnknownPreservedAsBase(relay);
                    TestHelper.Assert(false);
                }
                catch (Preserved2 ex)
                {
                    TestHelper.Assert(ex.b.Equals("base"));
                    TestHelper.Assert(ex.kp.Equals("preserved"));
                    TestHelper.Assert(ex.kpd.Equals("derived"));
                    TestHelper.Assert(ex.p1 !.GetType().GetIceTypeId() !.Equals(typeof(PreservedClass).GetIceTypeId()));
                    var pc = ex.p1 as PreservedClass;
                    TestHelper.Assert(pc !.bc.Equals("bc"));
                    TestHelper.Assert(pc !.pc.Equals("pc"));
                    TestHelper.Assert(ex.p2 == ex.p1);
                }
                catch (OperationNotExistException)
                {
                }
                catch (Exception)
                {
                    TestHelper.Assert(false);
                }

                try
                {
                    testPrx.relayUnknownPreservedAsKnownPreserved(relay);
                    TestHelper.Assert(false);
                }
                catch (Preserved2 ex)
                {
                    TestHelper.Assert(ex.b.Equals("base"));
                    TestHelper.Assert(ex.kp.Equals("preserved"));
                    TestHelper.Assert(ex.kpd.Equals("derived"));
                    TestHelper.Assert(ex.p1 !.GetType().GetIceTypeId() !.Equals(typeof(PreservedClass).GetIceTypeId()));
                    var pc = ex.p1 as PreservedClass;
                    TestHelper.Assert(pc !.bc.Equals("bc"));
                    TestHelper.Assert(pc !.pc.Equals("pc"));
                    TestHelper.Assert(ex.p2 == ex.p1);
                }
                catch (OperationNotExistException)
                {
                }
                catch (Exception)
                {
                    TestHelper.Assert(false);
                }

                try
                {
                    testPrx.relayClientPrivateException(relay);
                    TestHelper.Assert(false);
                }
                catch (ClientPrivateException ex)
                {
                    TestHelper.Assert(ex.cpe == "ClientPrivate");
                }
                catch (System.Exception)
                {
                    TestHelper.Assert(false);
                }

                adapter.Destroy();
            }
            output.WriteLine("ok");

            return(testPrx);
        }
Exemplo n.º 18
0
    public static ITestIntfPrx allTests(Test.TestHelper helper, bool collocated)
    {
        Communicator communicator = helper.communicator();
        var          output       = helper.getWriter();

        output.Write("testing stringToProxy... ");
        output.Flush();
        string @ref  = "Test:" + helper.getTestEndpoint(0) + " -t 2000";
        var    @base = IObjectPrx.Parse(@ref, communicator);

        test(@base != null);
        output.WriteLine("ok");

        output.Write("testing checked cast... ");
        output.Flush();
        ITestIntfPrx testPrx = ITestIntfPrx.CheckedCast(@base);

        test(testPrx != null);
        test(testPrx.Equals(@base));
        output.WriteLine("ok");

        output.Write("base... ");
        output.Flush();
        {
            try
            {
                testPrx.baseAsBase();
                test(false);
            }
            catch (Base b)
            {
                test(b.b.Equals("Base.b"));
                test(b.GetType().FullName.Equals("Test.Base"));
            }
            catch (System.Exception)
            {
                test(false);
            }
        }
        output.WriteLine("ok");

        output.Write("base (AMI)... ");
        output.Flush();
        {
            try
            {
                testPrx.baseAsBaseAsync().Wait();
                test(false);
            }
            catch (AggregateException ae)
            {
                try
                {
                    throw ae.InnerException;
                }
                catch (Base b)
                {
                    test(b.b.Equals("Base.b"));
                    test(b.GetType().Name.Equals("Base"));
                }
                catch (System.Exception)
                {
                    test(false);
                }
            }
        }
        output.WriteLine("ok");

        output.Write("slicing of unknown derived... ");
        output.Flush();
        {
            try
            {
                testPrx.unknownDerivedAsBase();
                test(false);
            }
            catch (Base b)
            {
                test(b.b.Equals("UnknownDerived.b"));
                test(b.GetType().FullName.Equals("Test.Base"));
            }
            catch (System.Exception)
            {
                test(false);
            }
        }
        output.WriteLine("ok");

        output.Write("slicing of unknown derived (AMI)... ");
        output.Flush();
        {
            try
            {
                testPrx.unknownDerivedAsBaseAsync().Wait();
                test(false);
            }
            catch (AggregateException ae)
            {
                try
                {
                    throw ae.InnerException;
                }
                catch (Base b)
                {
                    test(b.b.Equals("UnknownDerived.b"));
                    test(b.GetType().Name.Equals("Base"));
                }
                catch (System.Exception)
                {
                    test(false);
                }
            }
        }
        output.WriteLine("ok");

        output.Write("non-slicing of known derived as base... ");
        output.Flush();
        {
            try
            {
                testPrx.knownDerivedAsBase();
                test(false);
            }
            catch (KnownDerived k)
            {
                test(k.b.Equals("KnownDerived.b"));
                test(k.kd.Equals("KnownDerived.kd"));
                test(k.GetType().FullName.Equals("Test.KnownDerived"));
            }
            catch (System.Exception)
            {
                test(false);
            }
        }
        output.WriteLine("ok");

        output.Write("non-slicing of known derived as base (AMI)... ");
        output.Flush();
        {
            try
            {
                testPrx.knownDerivedAsBaseAsync().Wait();
                test(false);
            }
            catch (AggregateException ae)
            {
                try
                {
                    throw ae.InnerException;
                }
                catch (KnownDerived k)
                {
                    test(k.b.Equals("KnownDerived.b"));
                    test(k.kd.Equals("KnownDerived.kd"));
                    test(k.GetType().Name.Equals("KnownDerived"));
                }
                catch (System.Exception)
                {
                    test(false);
                }
            }
        }
        output.WriteLine("ok");

        output.Write("non-slicing of known derived as derived... ");
        output.Flush();
        {
            try
            {
                testPrx.knownDerivedAsKnownDerived();
                test(false);
            }
            catch (KnownDerived k)
            {
                test(k.b.Equals("KnownDerived.b"));
                test(k.kd.Equals("KnownDerived.kd"));
                test(k.GetType().FullName.Equals("Test.KnownDerived"));
            }
            catch (System.Exception)
            {
                test(false);
            }
        }
        output.WriteLine("ok");

        output.Write("non-slicing of known derived as derived (AMI)... ");
        output.Flush();
        {
            try
            {
                testPrx.knownDerivedAsKnownDerivedAsync().Wait();
                test(false);
            }
            catch (AggregateException ae)
            {
                try
                {
                    throw ae.InnerException;
                }
                catch (KnownDerived k)
                {
                    test(k.b.Equals("KnownDerived.b"));
                    test(k.kd.Equals("KnownDerived.kd"));
                    test(k.GetType().Name.Equals("KnownDerived"));
                }
                catch (System.Exception)
                {
                    test(false);
                }
            }
        }
        output.WriteLine("ok");

        output.Write("slicing of unknown intermediate as base... ");
        output.Flush();
        {
            try
            {
                testPrx.unknownIntermediateAsBase();
                test(false);
            }
            catch (Base b)
            {
                test(b.b.Equals("UnknownIntermediate.b"));
                test(b.GetType().FullName.Equals("Test.Base"));
            }
            catch (System.Exception)
            {
                test(false);
            }
        }
        output.WriteLine("ok");

        output.Write("slicing of unknown intermediate as base (AMI)... ");
        output.Flush();
        {
            try
            {
                testPrx.unknownIntermediateAsBaseAsync().Wait();
                test(false);
            }
            catch (AggregateException ae)
            {
                try
                {
                    throw ae.InnerException;
                }
                catch (Base b)
                {
                    test(b.b.Equals("UnknownIntermediate.b"));
                    test(b.GetType().Name.Equals("Base"));
                }
                catch (System.Exception)
                {
                    test(false);
                }
            }
        }
        output.WriteLine("ok");

        output.Write("slicing of known intermediate as base... ");
        output.Flush();
        {
            try
            {
                testPrx.knownIntermediateAsBase();
                test(false);
            }
            catch (KnownIntermediate ki)
            {
                test(ki.b.Equals("KnownIntermediate.b"));
                test(ki.ki.Equals("KnownIntermediate.ki"));
                test(ki.GetType().FullName.Equals("Test.KnownIntermediate"));
            }
            catch (System.Exception)
            {
                test(false);
            }
        }
        output.WriteLine("ok");

        output.Write("slicing of known intermediate as base (AMI)... ");
        output.Flush();
        {
            try
            {
                testPrx.knownIntermediateAsBaseAsync().Wait();
                test(false);
            }
            catch (AggregateException ae)
            {
                try
                {
                    throw ae.InnerException;
                }
                catch (KnownIntermediate ki)
                {
                    test(ki.b.Equals("KnownIntermediate.b"));
                    test(ki.ki.Equals("KnownIntermediate.ki"));
                    test(ki.GetType().Name.Equals("KnownIntermediate"));
                }
                catch (System.Exception)
                {
                    test(false);
                }
            }
        }
        output.WriteLine("ok");

        output.Write("slicing of known most derived as base... ");
        output.Flush();
        {
            try
            {
                testPrx.knownMostDerivedAsBase();
                test(false);
            }
            catch (KnownMostDerived kmd)
            {
                test(kmd.b.Equals("KnownMostDerived.b"));
                test(kmd.ki.Equals("KnownMostDerived.ki"));
                test(kmd.kmd.Equals("KnownMostDerived.kmd"));
                test(kmd.GetType().FullName.Equals("Test.KnownMostDerived"));
            }
            catch (System.Exception)
            {
                test(false);
            }
        }
        output.WriteLine("ok");

        output.Write("slicing of known most derived as base (AMI)... ");
        output.Flush();
        {
            try
            {
                testPrx.knownMostDerivedAsBaseAsync().Wait();
                test(false);
            }
            catch (AggregateException ae)
            {
                try
                {
                    throw ae.InnerException;
                }
                catch (KnownMostDerived kmd)
                {
                    test(kmd.b.Equals("KnownMostDerived.b"));
                    test(kmd.ki.Equals("KnownMostDerived.ki"));
                    test(kmd.kmd.Equals("KnownMostDerived.kmd"));
                    test(kmd.GetType().Name.Equals("KnownMostDerived"));
                }
                catch (System.Exception)
                {
                    test(false);
                }
            }
        }
        output.WriteLine("ok");

        output.Write("non-slicing of known intermediate as intermediate... ");
        output.Flush();
        {
            try
            {
                testPrx.knownIntermediateAsKnownIntermediate();
                test(false);
            }
            catch (KnownIntermediate ki)
            {
                test(ki.b.Equals("KnownIntermediate.b"));
                test(ki.ki.Equals("KnownIntermediate.ki"));
                test(ki.GetType().FullName.Equals("Test.KnownIntermediate"));
            }
            catch (System.Exception)
            {
                test(false);
            }
        }
        output.WriteLine("ok");

        output.Write("non-slicing of known intermediate as intermediate (AMI)... ");
        output.Flush();
        {
            try
            {
                testPrx.knownIntermediateAsKnownIntermediateAsync().Wait();
                test(false);
            }
            catch (AggregateException ae)
            {
                try
                {
                    throw ae.InnerException;
                }
                catch (KnownIntermediate ki)
                {
                    test(ki.b.Equals("KnownIntermediate.b"));
                    test(ki.ki.Equals("KnownIntermediate.ki"));
                    test(ki.GetType().Name.Equals("KnownIntermediate"));
                }
                catch (System.Exception)
                {
                    test(false);
                }
            }
        }
        output.WriteLine("ok");

        output.Write("non-slicing of known most derived as intermediate... ");
        output.Flush();
        {
            try
            {
                testPrx.knownMostDerivedAsKnownIntermediate();
                test(false);
            }
            catch (KnownMostDerived kmd)
            {
                test(kmd.b.Equals("KnownMostDerived.b"));
                test(kmd.ki.Equals("KnownMostDerived.ki"));
                test(kmd.kmd.Equals("KnownMostDerived.kmd"));
                test(kmd.GetType().FullName.Equals("Test.KnownMostDerived"));
            }
            catch (System.Exception)
            {
                test(false);
            }
        }
        output.WriteLine("ok");

        output.Write("non-slicing of known most derived as intermediate (AMI)... ");
        output.Flush();
        {
            try
            {
                testPrx.knownMostDerivedAsKnownIntermediateAsync().Wait();
                test(false);
            }
            catch (AggregateException ae)
            {
                try
                {
                    throw ae.InnerException;
                }
                catch (KnownMostDerived kmd)
                {
                    test(kmd.b.Equals("KnownMostDerived.b"));
                    test(kmd.ki.Equals("KnownMostDerived.ki"));
                    test(kmd.kmd.Equals("KnownMostDerived.kmd"));
                    test(kmd.GetType().Name.Equals("KnownMostDerived"));
                }
                catch (System.Exception)
                {
                    test(false);
                }
            }
        }
        output.WriteLine("ok");

        output.Write("non-slicing of known most derived as most derived... ");
        output.Flush();
        {
            try
            {
                testPrx.knownMostDerivedAsKnownMostDerived();
                test(false);
            }
            catch (KnownMostDerived kmd)
            {
                test(kmd.b.Equals("KnownMostDerived.b"));
                test(kmd.ki.Equals("KnownMostDerived.ki"));
                test(kmd.kmd.Equals("KnownMostDerived.kmd"));
                test(kmd.GetType().FullName.Equals("Test.KnownMostDerived"));
            }
            catch (System.Exception)
            {
                test(false);
            }
        }
        output.WriteLine("ok");

        output.Write("non-slicing of known most derived as most derived (AMI)... ");
        output.Flush();
        {
            try
            {
                testPrx.knownMostDerivedAsKnownMostDerivedAsync().Wait();
                test(false);
            }
            catch (AggregateException ae)
            {
                try
                {
                    throw ae.InnerException;
                }
                catch (KnownMostDerived kmd)
                {
                    test(kmd.b.Equals("KnownMostDerived.b"));
                    test(kmd.ki.Equals("KnownMostDerived.ki"));
                    test(kmd.kmd.Equals("KnownMostDerived.kmd"));
                    test(kmd.GetType().Name.Equals("KnownMostDerived"));
                }
                catch (System.Exception)
                {
                    test(false);
                }
            }
        }
        output.WriteLine("ok");

        output.Write("slicing of unknown most derived, known intermediate as base... ");
        output.Flush();
        {
            try
            {
                testPrx.unknownMostDerived1AsBase();
                test(false);
            }
            catch (KnownIntermediate ki)
            {
                test(ki.b.Equals("UnknownMostDerived1.b"));
                test(ki.ki.Equals("UnknownMostDerived1.ki"));
                test(ki.GetType().FullName.Equals("Test.KnownIntermediate"));
            }
            catch (System.Exception)
            {
                test(false);
            }
        }
        output.WriteLine("ok");

        output.Write("slicing of unknown most derived, known intermediate as base (AMI)... ");
        output.Flush();
        {
            try
            {
                testPrx.unknownMostDerived1AsBaseAsync().Wait();
                test(false);
            }
            catch (AggregateException ae)
            {
                try
                {
                    throw ae.InnerException;
                }
                catch (KnownIntermediate ki)
                {
                    test(ki.b.Equals("UnknownMostDerived1.b"));
                    test(ki.ki.Equals("UnknownMostDerived1.ki"));
                    test(ki.GetType().Name.Equals("KnownIntermediate"));
                }
                catch (System.Exception)
                {
                    test(false);
                }
            }
        }
        output.WriteLine("ok");

        output.Write("slicing of unknown most derived, known intermediate as intermediate... ");
        output.Flush();
        {
            try
            {
                testPrx.unknownMostDerived1AsKnownIntermediate();
                test(false);
            }
            catch (KnownIntermediate ki)
            {
                test(ki.b.Equals("UnknownMostDerived1.b"));
                test(ki.ki.Equals("UnknownMostDerived1.ki"));
                test(ki.GetType().FullName.Equals("Test.KnownIntermediate"));
            }
            catch (System.Exception)
            {
                test(false);
            }
        }
        output.WriteLine("ok");

        output.Write("slicing of unknown most derived, known intermediate as intermediate (AMI)... ");
        output.Flush();
        {
            try
            {
                testPrx.unknownMostDerived1AsKnownIntermediateAsync().Wait();
                test(false);
            }
            catch (AggregateException ae)
            {
                try
                {
                    throw ae.InnerException;
                }
                catch (KnownIntermediate ki)
                {
                    test(ki.b.Equals("UnknownMostDerived1.b"));
                    test(ki.ki.Equals("UnknownMostDerived1.ki"));
                    test(ki.GetType().Name.Equals("KnownIntermediate"));
                }
                catch (System.Exception)
                {
                    test(false);
                }
            }
        }
        output.WriteLine("ok");

        output.Write("slicing of unknown most derived, unknown intermediate thrown as base... ");
        output.Flush();
        {
            try
            {
                testPrx.unknownMostDerived2AsBase();
                test(false);
            }
            catch (Base b)
            {
                test(b.b.Equals("UnknownMostDerived2.b"));
                test(b.GetType().FullName.Equals("Test.Base"));
            }
            catch (System.Exception)
            {
                test(false);
            }
        }
        output.WriteLine("ok");

        output.Write("slicing of unknown most derived, unknown intermediate thrown as base (AMI)... ");
        output.Flush();
        {
            try
            {
                testPrx.unknownMostDerived2AsBaseAsync().Wait();
                test(false);
            }
            catch (AggregateException ae)
            {
                try
                {
                    throw ae.InnerException;
                }
                catch (Base b)
                {
                    test(b.b.Equals("UnknownMostDerived2.b"));
                    test(b.GetType().Name.Equals("Base"));
                }
                catch (System.Exception)
                {
                    test(false);
                }
            }
        }
        output.WriteLine("ok");

        output.Write("unknown most derived in compact format... ");
        output.Flush();
        {
            try
            {
                testPrx.unknownMostDerived2AsBaseCompact();
                test(false);
            }
            catch (Base)
            {
                test(false);
            }
            catch (Ice.UnknownUserException)
            {
                //
                // A MarshalException is raised for the compact format because the
                // most-derived type is unknown and the exception cannot be sliced.
                //
            }
            catch (Ice.OperationNotExistException)
            {
            }
            catch (System.Exception)
            {
                test(false);
            }
        }
        output.WriteLine("ok");

        output.Write("preserved exceptions... ");
        output.Flush();
        {
            try
            {
                testPrx.unknownPreservedAsBase();
                test(false);
            }
            catch (Base ex)
            {
                IReadOnlyList <Ice.SliceInfo> slices = ex.GetSlicedData().Value.Slices;
                test(slices.Count == 2);
                test(slices[1].TypeId.Equals("::Test::SPreserved1"));
                test(slices[0].TypeId.Equals("::Test::SPreserved2"));
            }

            try
            {
                testPrx.unknownPreservedAsKnownPreserved();
                test(false);
            }
            catch (KnownPreserved ex)
            {
                test(ex.kp.Equals("preserved"));
                IReadOnlyList <Ice.SliceInfo> slices = ex.GetSlicedData().Value.Slices;
                test(slices.Count == 2);
                test(slices[1].TypeId.Equals("::Test::SPreserved1"));
                test(slices[0].TypeId.Equals("::Test::SPreserved2"));
            }

            ObjectAdapter adapter = communicator.CreateObjectAdapter("");
            IRelayPrx     relay   = adapter.Add(new Relay(), IRelayPrx.Factory);
            adapter.Activate();
            testPrx.GetConnection().SetAdapter(adapter);

            try
            {
                testPrx.relayKnownPreservedAsBase(relay);
                test(false);
            }
            catch (KnownPreservedDerived ex)
            {
                test(ex.b.Equals("base"));
                test(ex.kp.Equals("preserved"));
                test(ex.kpd.Equals("derived"));
            }
            catch (Ice.OperationNotExistException)
            {
            }
            catch (System.Exception)
            {
                test(false);
            }

            try
            {
                testPrx.relayKnownPreservedAsKnownPreserved(relay);
                test(false);
            }
            catch (KnownPreservedDerived ex)
            {
                test(ex.b.Equals("base"));
                test(ex.kp.Equals("preserved"));
                test(ex.kpd.Equals("derived"));
            }
            catch (Ice.OperationNotExistException)
            {
            }
            catch (System.Exception)
            {
                test(false);
            }

            try
            {
                testPrx.relayUnknownPreservedAsBase(relay);
                test(false);
            }
            catch (Preserved2 ex)
            {
                test(ex.b.Equals("base"));
                test(ex.kp.Equals("preserved"));
                test(ex.kpd.Equals("derived"));
                test(ex.p1.GetType().GetIceTypeId().Equals(typeof(PreservedClass).GetIceTypeId()));
                PreservedClass pc = ex.p1 as PreservedClass;
                test(pc.bc.Equals("bc"));
                test(pc.pc.Equals("pc"));
                test(ex.p2 == ex.p1);
            }
            catch (Ice.OperationNotExistException)
            {
            }
            catch (System.Exception)
            {
                test(false);
            }

            try
            {
                testPrx.relayUnknownPreservedAsKnownPreserved(relay);
                test(false);
            }
            catch (Preserved2 ex)
            {
                test(ex.b.Equals("base"));
                test(ex.kp.Equals("preserved"));
                test(ex.kpd.Equals("derived"));
                test(ex.p1.GetType().GetIceTypeId().Equals(typeof(PreservedClass).GetIceTypeId()));
                PreservedClass pc = ex.p1 as PreservedClass;
                test(pc.bc.Equals("bc"));
                test(pc.pc.Equals("pc"));
                test(ex.p2 == ex.p1);
            }
            catch (Ice.OperationNotExistException)
            {
            }
            catch (System.Exception)
            {
                test(false);
            }

            adapter.Destroy();
        }
        output.WriteLine("ok");

        return(testPrx);
    }
Exemplo n.º 19
0
        public static async Task RunAsync(TestHelper helper)
        {
            Communicator communicator = helper.Communicator;

            TextWriter output = helper.Output;
            output.Write("testing stringToProxy... ");
            output.Flush();
            var testPrx = ITestIntfPrx.Parse(helper.GetTestProxy("Test", 0), communicator);
            output.WriteLine("ok");

            output.Write("base... ");
            output.Flush();
            {
                try
                {
                    testPrx.BaseAsBase();
                    TestHelper.Assert(false);
                }
                catch (Base b)
                {
                    TestHelper.Assert(b.B.Equals("Base.b"));
                    TestHelper.Assert(b.GetType().FullName!.Equals("ZeroC.Ice.Test.Slicing.Exceptions.Base"));
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("base (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.BaseAsBaseAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (Base b)
                    {
                        TestHelper.Assert(b.B.Equals("Base.b"));
                        TestHelper.Assert(b.GetType().Name.Equals("Base"));
                    }
                    catch
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown derived... ");
            output.Flush();
            {
                try
                {
                    testPrx.UnknownDerivedAsBase();
                    TestHelper.Assert(false);
                }
                catch (Base b)
                {
                    TestHelper.Assert(b.B.Equals("UnknownDerived.b"));
                    TestHelper.Assert(b.GetType().FullName!.Equals("ZeroC.Ice.Test.Slicing.Exceptions.Base"));
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown derived (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.UnknownDerivedAsBaseAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (Base b)
                    {
                        TestHelper.Assert(b.B.Equals("UnknownDerived.b"));
                        TestHelper.Assert(b.GetType().Name.Equals("Base"));
                    }
                    catch
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known derived as base... ");
            output.Flush();
            {
                try
                {
                    testPrx.KnownDerivedAsBase();
                    TestHelper.Assert(false);
                }
                catch (KnownDerived k)
                {
                    TestHelper.Assert(k.B.Equals("KnownDerived.b"));
                    TestHelper.Assert(k.Kd.Equals("KnownDerived.kd"));
                    TestHelper.Assert(k.GetType().FullName!.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownDerived"));
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known derived as base (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.KnownDerivedAsBaseAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownDerived k)
                    {
                        TestHelper.Assert(k.B.Equals("KnownDerived.b"));
                        TestHelper.Assert(k.Kd.Equals("KnownDerived.kd"));
                        TestHelper.Assert(k.GetType().Name.Equals("KnownDerived"));
                    }
                    catch
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known derived as derived... ");
            output.Flush();
            {
                try
                {
                    testPrx.KnownDerivedAsKnownDerived();
                    TestHelper.Assert(false);
                }
                catch (KnownDerived k)
                {
                    TestHelper.Assert(k.B.Equals("KnownDerived.b"));
                    TestHelper.Assert(k.Kd.Equals("KnownDerived.kd"));
                    TestHelper.Assert(k.GetType().FullName!.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownDerived"));
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known derived as derived (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.KnownDerivedAsKnownDerivedAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownDerived k)
                    {
                        TestHelper.Assert(k.B.Equals("KnownDerived.b"));
                        TestHelper.Assert(k.Kd.Equals("KnownDerived.kd"));
                        TestHelper.Assert(k.GetType().Name.Equals("KnownDerived"));
                    }
                    catch
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown intermediate as base... ");
            output.Flush();
            {
                try
                {
                    testPrx.UnknownIntermediateAsBase();
                    TestHelper.Assert(false);
                }
                catch (Base b)
                {
                    TestHelper.Assert(b.B.Equals("UnknownIntermediate.b"));
                    TestHelper.Assert(b.GetType().FullName!.Equals("ZeroC.Ice.Test.Slicing.Exceptions.Base"));
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown intermediate as base (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.UnknownIntermediateAsBaseAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (Base b)
                    {
                        TestHelper.Assert(b.B.Equals("UnknownIntermediate.b"));
                        TestHelper.Assert(b.GetType().Name.Equals("Base"));
                    }
                    catch
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of known intermediate as base... ");
            output.Flush();
            {
                try
                {
                    testPrx.KnownIntermediateAsBase();
                    TestHelper.Assert(false);
                }
                catch (KnownIntermediate ki)
                {
                    TestHelper.Assert(ki.B.Equals("KnownIntermediate.b"));
                    TestHelper.Assert(ki.Ki.Equals("KnownIntermediate.ki"));
                    TestHelper.Assert(ki.GetType().FullName!.Equals(
                        "ZeroC.Ice.Test.Slicing.Exceptions.KnownIntermediate"));
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of known intermediate as base (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.KnownIntermediateAsBaseAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownIntermediate ki)
                    {
                        TestHelper.Assert(ki.B.Equals("KnownIntermediate.b"));
                        TestHelper.Assert(ki.Ki.Equals("KnownIntermediate.ki"));
                        TestHelper.Assert(ki.GetType().Name.Equals("KnownIntermediate"));
                    }
                    catch
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of known most derived as base... ");
            output.Flush();
            {
                try
                {
                    testPrx.KnownMostDerivedAsBase();
                    TestHelper.Assert(false);
                }
                catch (KnownMostDerived kmd)
                {
                    TestHelper.Assert(kmd.B.Equals("KnownMostDerived.b"));
                    TestHelper.Assert(kmd.Ki.Equals("KnownMostDerived.ki"));
                    TestHelper.Assert(kmd.Kmd.Equals("KnownMostDerived.kmd"));
                    TestHelper.Assert(kmd.GetType().FullName!.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownMostDerived"));
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of known most derived as base (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.KnownMostDerivedAsBaseAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownMostDerived kmd)
                    {
                        TestHelper.Assert(kmd.B.Equals("KnownMostDerived.b"));
                        TestHelper.Assert(kmd.Ki.Equals("KnownMostDerived.ki"));
                        TestHelper.Assert(kmd.Kmd.Equals("KnownMostDerived.kmd"));
                        TestHelper.Assert(kmd.GetType().Name.Equals("KnownMostDerived"));
                    }
                    catch
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known intermediate as intermediate... ");
            output.Flush();
            {
                try
                {
                    testPrx.KnownIntermediateAsKnownIntermediate();
                    TestHelper.Assert(false);
                }
                catch (KnownIntermediate ki)
                {
                    TestHelper.Assert(ki.B.Equals("KnownIntermediate.b"));
                    TestHelper.Assert(ki.Ki.Equals("KnownIntermediate.ki"));
                    TestHelper.Assert(ki.GetType().FullName!.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownIntermediate"));
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known intermediate as intermediate (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.KnownIntermediateAsKnownIntermediateAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownIntermediate ki)
                    {
                        TestHelper.Assert(ki.B.Equals("KnownIntermediate.b"));
                        TestHelper.Assert(ki.Ki.Equals("KnownIntermediate.ki"));
                        TestHelper.Assert(ki.GetType().Name.Equals("KnownIntermediate"));
                    }
                    catch
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known most derived as intermediate... ");
            output.Flush();
            {
                try
                {
                    testPrx.KnownMostDerivedAsKnownIntermediate();
                    TestHelper.Assert(false);
                }
                catch (KnownMostDerived kmd)
                {
                    TestHelper.Assert(kmd.B.Equals("KnownMostDerived.b"));
                    TestHelper.Assert(kmd.Ki.Equals("KnownMostDerived.ki"));
                    TestHelper.Assert(kmd.Kmd.Equals("KnownMostDerived.kmd"));
                    TestHelper.Assert(kmd.GetType().FullName!.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownMostDerived"));
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known most derived as intermediate (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.KnownMostDerivedAsKnownIntermediateAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownMostDerived kmd)
                    {
                        TestHelper.Assert(kmd.B.Equals("KnownMostDerived.b"));
                        TestHelper.Assert(kmd.Ki.Equals("KnownMostDerived.ki"));
                        TestHelper.Assert(kmd.Kmd.Equals("KnownMostDerived.kmd"));
                        TestHelper.Assert(kmd.GetType().Name.Equals("KnownMostDerived"));
                    }
                    catch
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known most derived as most derived... ");
            output.Flush();
            {
                try
                {
                    testPrx.KnownMostDerivedAsKnownMostDerived();
                    TestHelper.Assert(false);
                }
                catch (KnownMostDerived kmd)
                {
                    TestHelper.Assert(kmd.B.Equals("KnownMostDerived.b"));
                    TestHelper.Assert(kmd.Ki.Equals("KnownMostDerived.ki"));
                    TestHelper.Assert(kmd.Kmd.Equals("KnownMostDerived.kmd"));
                    TestHelper.Assert(kmd.GetType().FullName!.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownMostDerived"));
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("non-slicing of known most derived as most derived (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.KnownMostDerivedAsKnownMostDerivedAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownMostDerived kmd)
                    {
                        TestHelper.Assert(kmd.B.Equals("KnownMostDerived.b"));
                        TestHelper.Assert(kmd.Ki.Equals("KnownMostDerived.ki"));
                        TestHelper.Assert(kmd.Kmd.Equals("KnownMostDerived.kmd"));
                        TestHelper.Assert(kmd.GetType().Name.Equals("KnownMostDerived"));
                    }
                    catch
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown most derived, known intermediate as base... ");
            output.Flush();
            {
                try
                {
                    testPrx.UnknownMostDerived1AsBase();
                    TestHelper.Assert(false);
                }
                catch (KnownIntermediate ki)
                {
                    TestHelper.Assert(ki.B.Equals("UnknownMostDerived1.b"));
                    TestHelper.Assert(ki.Ki.Equals("UnknownMostDerived1.ki"));
                    TestHelper.Assert(ki.GetType().FullName!.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownIntermediate"));
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown most derived, known intermediate as base (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.UnknownMostDerived1AsBaseAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownIntermediate ki)
                    {
                        TestHelper.Assert(ki.B.Equals("UnknownMostDerived1.b"));
                        TestHelper.Assert(ki.Ki.Equals("UnknownMostDerived1.ki"));
                        TestHelper.Assert(ki.GetType().Name.Equals("KnownIntermediate"));
                    }
                    catch
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown most derived, known intermediate as intermediate... ");
            output.Flush();
            {
                try
                {
                    testPrx.UnknownMostDerived1AsKnownIntermediate();
                    TestHelper.Assert(false);
                }
                catch (KnownIntermediate ki)
                {
                    TestHelper.Assert(ki.B.Equals("UnknownMostDerived1.b"));
                    TestHelper.Assert(ki.Ki.Equals("UnknownMostDerived1.ki"));
                    TestHelper.Assert(ki.GetType().FullName!.Equals("ZeroC.Ice.Test.Slicing.Exceptions.KnownIntermediate"));
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown most derived, known intermediate as intermediate (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.UnknownMostDerived1AsKnownIntermediateAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (KnownIntermediate ki)
                    {
                        TestHelper.Assert(ki.B.Equals("UnknownMostDerived1.b"));
                        TestHelper.Assert(ki.Ki.Equals("UnknownMostDerived1.ki"));
                        TestHelper.Assert(ki.GetType().Name.Equals("KnownIntermediate"));
                    }
                    catch
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown most derived, unknown intermediate thrown as base... ");
            output.Flush();
            {
                try
                {
                    testPrx.UnknownMostDerived2AsBase();
                    TestHelper.Assert(false);
                }
                catch (Base b)
                {
                    TestHelper.Assert(b.B.Equals("UnknownMostDerived2.b"));
                    TestHelper.Assert(b.GetType().FullName!.Equals("ZeroC.Ice.Test.Slicing.Exceptions.Base"));
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("slicing of unknown most derived, unknown intermediate thrown as base (AMI)... ");
            output.Flush();
            {
                try
                {
                    testPrx.UnknownMostDerived2AsBaseAsync().Wait();
                    TestHelper.Assert(false);
                }
                catch (AggregateException ae)
                {
                    try
                    {
                        TestHelper.Assert(ae.InnerException != null);
                        throw ae.InnerException;
                    }
                    catch (Base b)
                    {
                        TestHelper.Assert(b.B.Equals("UnknownMostDerived2.b"));
                        TestHelper.Assert(b.GetType().Name.Equals("Base"));
                    }
                    catch
                    {
                        TestHelper.Assert(false);
                    }
                }
            }
            output.WriteLine("ok");

            output.Write("unknown most derived in compact format... ");
            output.Flush();
            {
                try
                {
                    testPrx.UnknownMostDerived2AsBaseCompact();
                    TestHelper.Assert(false);
                }
                catch (Base)
                {
                    // Exceptions are always marshaled in sliced format; format:compact applies only to in-parameters and
                    // return values.
                }
                catch (OperationNotExistException)
                {
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("completely unknown server-private exception... ");
            output.Flush();
            {
                try
                {
                    testPrx.ServerPrivateException();
                    TestHelper.Assert(false);
                }
                catch (RemoteException ex)
                {
                    SlicedData slicedData = ex.GetSlicedData()!.Value;
                    TestHelper.Assert(slicedData.Slices.Count == 1);
                    TestHelper.Assert(slicedData.Slices[0].TypeId! == "::ZeroC::Ice::Test::Slicing::Exceptions::ServerPrivateException");
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");

            output.Write("preserved exceptions... ");
            output.Flush();
            {
                try
                {
                    testPrx.UnknownPreservedAsBase();
                    TestHelper.Assert(false);
                }
                catch (Base ex)
                {
                    IReadOnlyList<SliceInfo> slices = ex.GetSlicedData()!.Value.Slices;
                    TestHelper.Assert(slices.Count == 2);
                    TestHelper.Assert(slices[1].TypeId!.Equals("::ZeroC::Ice::Test::Slicing::Exceptions::SPreserved1"));
                    TestHelper.Assert(slices[0].TypeId!.Equals("::ZeroC::Ice::Test::Slicing::Exceptions::SPreserved2"));
                }

                try
                {
                    testPrx.UnknownPreservedAsKnownPreserved();
                    TestHelper.Assert(false);
                }
                catch (KnownPreserved ex)
                {
                    TestHelper.Assert(ex.Kp.Equals("preserved"));
                    IReadOnlyList<SliceInfo> slices = ex.GetSlicedData()!.Value.Slices;
                    TestHelper.Assert(slices.Count == 2);
                    TestHelper.Assert(slices[1].TypeId!.Equals("::ZeroC::Ice::Test::Slicing::Exceptions::SPreserved1"));
                    TestHelper.Assert(slices[0].TypeId!.Equals("::ZeroC::Ice::Test::Slicing::Exceptions::SPreserved2"));
                }

                await using var adapter = communicator.CreateObjectAdapter(protocol: helper.Protocol);
                IRelayPrx relay = adapter.AddWithUUID(new Relay(), IRelayPrx.Factory);
                await adapter.ActivateAsync();
                (await testPrx.GetConnectionAsync()).Adapter = adapter;

                try
                {
                    testPrx.RelayKnownPreservedAsBase(relay);
                    TestHelper.Assert(false);
                }
                catch (KnownPreservedDerived ex)
                {
                    TestHelper.Assert(ex.B.Equals("base"));
                    TestHelper.Assert(ex.Kp.Equals("preserved"));
                    TestHelper.Assert(ex.Kpd.Equals("derived"));
                }
                catch (OperationNotExistException)
                {
                }
                catch
                {
                    TestHelper.Assert(false);
                }

                try
                {
                    testPrx.RelayKnownPreservedAsKnownPreserved(relay);
                    TestHelper.Assert(false);
                }
                catch (KnownPreservedDerived ex)
                {
                    TestHelper.Assert(ex.B.Equals("base"));
                    TestHelper.Assert(ex.Kp.Equals("preserved"));
                    TestHelper.Assert(ex.Kpd.Equals("derived"));
                }
                catch (OperationNotExistException)
                {
                }
                catch
                {
                    TestHelper.Assert(false);
                }

                try
                {
                    testPrx.RelayUnknownPreservedAsBase(relay);
                    TestHelper.Assert(false);
                }
                catch (Preserved2 ex)
                {
                    TestHelper.Assert(ex.B.Equals("base"));
                    TestHelper.Assert(ex.Kp.Equals("preserved"));
                    TestHelper.Assert(ex.Kpd.Equals("derived"));
                    TestHelper.Assert(ex.P1!.GetType().GetIceTypeId()!.Equals(typeof(PreservedClass).GetIceTypeId()));
                    var pc = ex.P1 as PreservedClass;
                    TestHelper.Assert(pc!.Bc.Equals("bc"));
                    TestHelper.Assert(pc!.Pc.Equals("pc"));
                    TestHelper.Assert(ex.P2 == ex.P1);
                }
                catch (OperationNotExistException)
                {
                }
                catch
                {
                    TestHelper.Assert(false);
                }

                try
                {
                    testPrx.RelayUnknownPreservedAsKnownPreserved(relay);
                    TestHelper.Assert(false);
                }
                catch (Preserved2 ex)
                {
                    TestHelper.Assert(ex.B.Equals("base"));
                    TestHelper.Assert(ex.Kp.Equals("preserved"));
                    TestHelper.Assert(ex.Kpd.Equals("derived"));
                    TestHelper.Assert(ex.P1!.GetType().GetIceTypeId()!.Equals(typeof(PreservedClass).GetIceTypeId()));
                    var pc = ex.P1 as PreservedClass;
                    TestHelper.Assert(pc!.Bc.Equals("bc"));
                    TestHelper.Assert(pc!.Pc.Equals("pc"));
                    TestHelper.Assert(ex.P2 == ex.P1);
                }
                catch (OperationNotExistException)
                {
                }
                catch
                {
                    TestHelper.Assert(false);
                }

                try
                {
                    testPrx.RelayClientPrivateException(relay);
                    TestHelper.Assert(false);
                }
                catch (ClientPrivateException ex)
                {
                    TestHelper.Assert(ex.Cpe == "ClientPrivate");
                }
                catch
                {
                    TestHelper.Assert(false);
                }
            }
            output.WriteLine("ok");
            await testPrx.ShutdownAsync();
        }