コード例 #1
0
        public void TestMethod1()
        {
            Configure();

            var targetEvent = new TestEvent
            {
                Data = string.Format("Testing_{0}", Environment.TickCount)
            };

            this.WaitHandle = new ManualResetEvent(false);

            var completedHandler = new SubscriberCompletedExecutionHandler(
                delegate(ISubscriber sub, object target)
            {
                var testingEvent = target as TestEvent;
                Assert.IsNotNull(testingEvent);
                this.WaitHandle.Set();
            });

            Subscribers.Current
            .WithCreator(this.Creator)
            .WithAssembly <TestEvent>()
            .Subscribe <TestEvent>()
            .WithSubscriberCompletedAction(completedHandler);

            Publishers.Current
            .WithCreator(this.Creator)
            .WithAssembly <TestEvent>()
            .Publish <TestEvent>(targetEvent);

            this.WaitHandle.WaitOne();

            Assert.IsTrue(targetEvent.Processed, "Event wasn't handled during the unit test");
        }
コード例 #2
0
ファイル: Subscribers.cs プロジェクト: chenbigit/EventBus
 public Subscribers WithSubscriberCompletedAction(SubscriberCompletedExecutionHandler handler)
 {
     this.SubscriberCompletedExecution += handler;
     return(this);
 }