public void IncrementsObservationRegistrarOnObserve() { var subject1 = new EventSubject <int, IEventContext, TestModel>(_eventObservationRegistrar); subject1.Observe((e, c, m) => { }); _eventObservationRegistrar.Register[typeof(int)].ShouldBe(1); }
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); }
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); }
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); }
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); }
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); }