示例#1
0
        public async Task Start(IDictionary <string, List <string> > args)
        {
            await Task.Yield();

            var ta = new TestArgs(args);

            var s = ta.AE;
            var t = ta.BE;
            var a = new XPU(new XCfg(
                                new BeamerCfg()
            {
                Log = new BeamerLogCfg("a", ta.Log)
            },
                                new XLogCfg("a-SimpleExchange", ta.Log),
                                new HeapHighway(ushort.MaxValue)));

            var b = new XPU(new XCfg(
                                new BeamerCfg()
            {
                Log = new BeamerLogCfg("b", ta.Log)
            },
                                new XLogCfg("b-SimpleExchange", ta.Log),
                                new HeapHighway(ushort.MaxValue)));

            const string ADD_ONE = "addOne";

            try
            {
                b.RegisterAPI(ADD_ONE, add_one);

                a.Start(s, t);
                b.Start(t, s);

                await a.TargetIsActive();

                await b.TargetIsActive();

                using (var ix = await a.Request(ADD_ONE, 3))
                    if (!ix.IsOK || ix.Make <int>() != 4)
                    {
                        Passed         = false;
                        FailureMessage = "Request failure.";
                        return;
                    }

                Passed     = true;
                IsComplete = true;
            }
            catch (Exception ex)
            {
                Passed         = false;
                FailureMessage = ex.ToString();
            }
            finally
            {
                a.Dispose();
                b.Dispose();
            }
        }
示例#2
0
        public async Task Start(IDictionary <string, List <string> > args)
        {
            var ta = new TestArgs(args);

            var s = ta.AE;
            var t = ta.BE;

            var a = new XPU(new XCfg(
                                new BeamerCfg()
            {
                Log = new BeamerLogCfg("a", ta.Log)
            },
                                new XLogCfg("a-ResNotFound", ta.Log),
                                new HeapHighway(ushort.MaxValue)));

            var b = new XPU(new XCfg(
                                new BeamerCfg()
            {
                Log = new BeamerLogCfg("b", ta.Log)
            },
                                new XLogCfg("b-ResNotFound", ta.Log),
                                new HeapHighway(ushort.MaxValue)));

            try
            {
                a.Start(s, t);
                b.Start(t, s);

                await a.TargetIsActive();

                await b.TargetIsActive();

                using (var ix = await a.Request("NonExistingResKey", 3))
                    if (!ix.IsOK && ix.ErrorCode == (int)XErrorCode.ResourceNotFound)
                    {
                        Passed     = true;
                        IsComplete = true;
                    }

                if (!Passed.HasValue)
                {
                    Passed = false;
                }
            }
            catch (Exception ex)
            {
                Passed         = false;
                FailureMessage = ex.ToString();
            }
            finally
            {
                a.Dispose();
                b.Dispose();
            }
        }
示例#3
0
        public async Task Start(IDictionary <string, List <string> > args)
        {
            var ta = new TestArgs(args);

            var s = ta.AE;
            var t = ta.BE;

            var a = new XPU(new XCfg(
                                new BeamerCfg()
            {
                Log = new BeamerLogCfg("a", ta.Log)
            },
                                new XLogCfg("a-RemoteException", ta.Log),
                                new HeapHighway(ushort.MaxValue)));

            var b = new XPU(new XCfg(
                                new BeamerCfg()
            {
                Log = new BeamerLogCfg("b", ta.Log)
            },
                                new XLogCfg("b-RemoteException", ta.Log),
                                new HeapHighway(ushort.MaxValue)));

            try
            {
                string RES = "WillThrow";

                b.RegisterAPI(RES, (f) =>
                {
                    "Throwing NotSupportedException".AsInfo();

                    throw new NotSupportedException();
                });

                a.Start(s, t);
                b.Start(t, s);

                await a.TargetIsActive();

                await b.TargetIsActive();

                using (var ix = await a.Request(RES))
                    if (!ix.IsOK && ix.ErrorCode == (int)XErrorCode.SerializedException)
                    {
                        var ex = ix.Make <Exception>();

                        if (ex is NotSupportedException)
                        {
                            Passed     = true;
                            IsComplete = true;
                        }
                    }

                if (!Passed.HasValue)
                {
                    Passed = false;
                }
            }
            catch (Exception ex)
            {
                Passed         = false;
                FailureMessage = ex.ToString();
            }
            finally
            {
                a.Dispose();
                b.Dispose();
            }
        }