Ejemplo n.º 1
0
        public void Should_receive_a_fault_from_a_failed_request()
        {
            bool responedHendeled = false;
            bool faultHendeled    = false;

            CompleteEvent.WaitOne(TimeSpan.FromSeconds(2), true);

            LocalBus.PublishRequest(new InvalidRequest(), x =>
            {
                x.Handle <Replay>(r =>
                {
                    responedHendeled = true;
                    CompleteEvent.Set();
                });
                x.HandleFault((c, f) =>
                {
                    faultHendeled = true;
                    CompleteEvent.Set();
                });
            });

            CompleteEvent.WaitOne(Debugger.IsAttached ? 5.Minutes() : 20.Seconds(), true);

            Assert.That(responedHendeled, Is.False);
            Assert.That(faultHendeled, Is.True);
        }
Ejemplo n.º 2
0
        public void Should_receive_a_response_from_a_valid_request()
        {
            bool responseHandled = false;
            bool faultHandled    = false;

            CompleteEvent.WaitOne(TimeSpan.FromSeconds(2), true);

            LocalBus.PublishRequest(new ValidRequest(), x =>
            {
                x.Handle <Replay>(r =>
                {
                    responseHandled = true;
                    CompleteEvent.Set();
                });
                x.HandleFault((c, f) =>
                {
                    faultHandled = true;
                    CompleteEvent.Set();
                });
            });

            CompleteEvent.WaitOne(TimeSpan.FromSeconds(20), true);

            Assert.That(responseHandled, Is.True);
            Assert.That(faultHandled, Is.False);
        }
Ejemplo n.º 3
0
        void NotifyComplete()
        {
            if (_completed)
            {
                return;
            }

            lock (_lock)
            {
                _completed = true;

                CompleteEvent.Set();
            }

            lock (_completionCallbacks)
            {
                _completionCallbacks.Each(callback =>
                {
                    try
                    {
                        if (callback != null)
                        {
                            callback(this);
                        }
                    }
                    catch (Exception ex)
                    {
                        _log.Error("The request callback threw an exception", ex);
                    }
                });
            }
        }