Example #1
0
        public void IncrementsObservationRegistrarOnObserve()
        {
            var subject1 = new EventSubject <int, IEventContext, TestModel>(_eventObservationRegistrar);

            subject1.Observe((e, c, m) => { });
            _eventObservationRegistrar.Register[typeof(int)].ShouldBe(1);
        }
Example #2
0
        public void DecrementsObservationRegistrarOnObserve()
        {
            var         subject1   = new EventSubject <int, IEventContext, TestModel>(_eventObservationRegistrar);
            IDisposable disposable = subject1.Observe((e, c, m) => { });

            disposable.Dispose();
            _eventObservationRegistrar.Register[typeof(int)].ShouldBe(0);
        }
Example #3
0
 public void SubjectRemovesSubscriptionOnDispose()
 {
     var subject = new EventSubject<TestModel, int, IEventContext>();
     int received = 0;
     var disposable = subject.Observe((m, e, c) => received = e);
     subject.OnNext(_model, 1, _eventContext);
     Assert.AreEqual(1, received);
     disposable.Dispose();
     subject.OnNext(_model, 2, _eventContext);
     Assert.AreEqual(1, received);
 }
Example #4
0
        public void SubjectRemovesSubscriptionOnDispose()
        {
            var subject    = new EventSubject <int, IEventContext, TestModel>(_eventObservationRegistrar);
            int received   = 0;
            var disposable = subject.Observe((e, c, m) => received = e);

            subject.OnNext(1, _eventContext, _model);
            Assert.AreEqual(1, received);
            disposable.Dispose();
            subject.OnNext(2, _eventContext, _model);
            Assert.AreEqual(1, received);
        }
Example #5
0
 public void SubjectOnNextsItems()
 {
     var subject = new EventSubject<TestModel, int, IEventContext>();
     TestModel receivedModel = null;
     int receivedEvent = 0;
     IEventContext receivedContext = null;
     subject.Observe((m, e, c) =>
     {
         receivedModel = m;
         receivedEvent = e;
         receivedContext = c;
     });
     subject.OnNext(_model, 1, _eventContext);
     receivedModel.ShouldBeSameAs(_model);
     receivedEvent.ShouldBe(1);
     receivedContext.ShouldBeSameAs(_eventContext);
 }
Example #6
0
        public void SubjectOnNextsItems()
        {
            var           subject         = new EventSubject <int, IEventContext, TestModel>(_eventObservationRegistrar);
            TestModel     receivedModel   = null;
            int           receivedEvent   = 0;
            IEventContext receivedContext = null;

            subject.Observe((e, c, m) =>
            {
                receivedModel   = m;
                receivedEvent   = e;
                receivedContext = c;
            });
            subject.OnNext(1, _eventContext, _model);
            receivedModel.ShouldBeSameAs(_model);
            receivedEvent.ShouldBe(1);
            receivedContext.ShouldBeSameAs(_eventContext);
        }