コード例 #1
0
 public void passed_in_action_is_called()
 {
     int callCount = 0;
     var sub = new DisposableSubscription(new MethodInvocation<MessageA>(msg => callCount++));
     sub.Push(new MessageA());
     callCount.ShouldBeEqualTo(1);
 }
コード例 #2
0
 public void calling_disposer_raises_disposed_evt()
 {
     var disposeCalled = false;
     IDisposableSubscription sub = new DisposableSubscription(null);
     sub.Disposed += (s, e) => disposeCalled = true;
     sub.GetDisposer().Dispose();
     disposeCalled.ShouldBeTrue();
 }
コード例 #3
0
 public void Denial_of_shape_correctly_propagates()
 {
     var s =
         new DisposableSubscription(
             new FilteredSubscription<MessageA>(m => true,
                 new UiDispatchingSubscription(null,
                     new DenyingSubscription())));
     s.Deny.ShouldBeTrue();
 }
コード例 #4
0
        public void Adapter_subscriptions_can_also_be_disposed()
        {
            var b = new MethodScanner("Handle").MakeBuilder();
            var disposableSub = new DisposableSubscription(b.BuildSubscriptions(new SomeHandler()).First());
            ISubscriptionResolver resolver = new CompositeSubscription();
            resolver.Add(disposableSub);

            var subs = resolver.GetSubscriptionsFor(new MessageA());
            subs.ShouldHaveCount(1);

            disposableSub.GetDisposer().Dispose();

            subs = resolver.GetSubscriptionsFor(new MessageA());
            subs.ShouldHaveCount(0);
        }
コード例 #5
0
 public void Handle_type_derived_from_action()
 {
     int callCount = 0;
     var sub = new DisposableSubscription(new MethodInvocation<MessageA>(msg => callCount++));
     sub.Handles(typeof(MessageA)).ShouldBeTrue();
 }