示例#1
0
        public void ClientMessageSent()
        {
            const string content = "Oh, hello there.";

            var c = GetNewClientConnection();

            var test = new AsyncTest();

            this.provider.Start(MessageTypes);

            c.Disconnected += test.FailHandler;
            c.Connected    += (sender, e) =>
            {
                Task <bool> task = c.SendAsync(new MockMessage {
                    Content = content
                });
                task.Wait();

                if (task.Result)
                {
                    test.PassHandler(null, EventArgs.Empty);
                }
                else
                {
                    test.FailHandler(null, EventArgs.Empty);
                }
            };
            c.ConnectAsync(Target, MessageTypes);

            test.Assert(10000);
        }
示例#2
0
        public void Multiple_Passes_Failure()
        {
            var test = new AsyncTest(multiple: true);

            test.PassHandler(this, EventArgs.Empty);
            test.PassHandler(this, EventArgs.Empty);
            test.FailHandler(this, EventArgs.Empty);

            Assert.Throws <AssertionException> (() => test.Assert(10, failIfNotPassed: false));
        }
示例#3
0
        public void ConnectionFailed()
        {
            Assert.IsFalse(provider.IsRunning);

            var test = new AsyncTest();
            var c    = GetNewClientConnection();

            c.Connected    += test.FailHandler;
            c.Disconnected += (s, e) =>
            {
                if (e.Result == ConnectionResult.ConnectionFailed)
                {
                    test.PassHandler(s, e);
                }
                else
                {
                    test.FailHandler(s, e);
                }
            };

            c.ConnectAsync(Target, MessageTypes);

            test.Assert(40000);
        }