public async Task WhenCalled_ThenCallsBeforeDispatchOnAllMiddlewares() { var testAction = new TestAction(); var mockMiddleware = MockMiddlewareFactory.Create(); var subject = new TestStore(); await subject.InitializeAsync(); subject.AddMiddleware(mockMiddleware.Object); subject.Dispatch(testAction); mockMiddleware .Verify(x => x.BeforeDispatch(testAction), Times.Once); }
public void ExecutesBeforeDispatchActionOnMiddlewares() { var testAction = new TestAction(); var mockMiddleware = MockMiddlewareFactory.Create(); var subject = new Store(BrowserInteropStub); subject.AddMiddleware(mockMiddleware.Object); BrowserInteropStub._TriggerPageLoaded(); subject.Dispatch(testAction); mockMiddleware .Verify(x => x.BeforeDispatch(testAction), Times.Once); }
public void ExecutesBeforeDispatchActionOnMiddlewares() { var testAction = new TestAction(); var mockMiddleware = MockMiddlewareFactory.Create(); var subject = new Store(StoreInitializer); subject.Initialize(); subject.AddMiddleware(mockMiddleware.Object); StoreInitializer.Complete(); subject.Dispatch(testAction); mockMiddleware .Verify(x => x.BeforeDispatch(testAction), Times.Once); }
public void DoesNotSendActionToFeatures_WhenMiddlewareForbidsIt() { var testAction = new TestAction(); var mockFeature = MockFeatureFactory.Create(); var mockMiddleware = MockMiddlewareFactory.Create(); mockMiddleware .Setup(x => x.MayDispatchAction(testAction)) .Returns(false); var subject = new Store(BrowserInteropStub); BrowserInteropStub._TriggerPageLoaded(); subject.Dispatch(testAction); mockFeature .Verify(x => x.ReceiveDispatchNotificationFromStore(testAction), Times.Never); }
public async Task WhenMiddlewareForbidsIt_ThenDoesNotSendActionToFeatures() { var testAction = new TestAction(); var mockFeature = MockFeatureFactory.Create(); var mockMiddleware = MockMiddlewareFactory.Create(); mockMiddleware .Setup(x => x.MayDispatchAction(testAction)) .Returns(false); var subject = new TestStore(); await subject.InitializeAsync(); subject.Dispatch(testAction); mockFeature .Verify(x => x.ReceiveDispatchNotificationFromStore(testAction), Times.Never); }
public async Task WhenIsInsideMiddlewareChange_ThenDoesNotDispatchActions() { var mockMiddleware = MockMiddlewareFactory.Create(); var subject = new TestStore(); await subject.InitializeAsync(); subject.AddMiddleware(mockMiddleware.Object); var testAction = new TestAction(); using (subject.BeginInternalMiddlewareChange()) { subject.Dispatch(testAction); } mockMiddleware.Verify(x => x.MayDispatchAction(testAction), Times.Never); }
public void DoesNotDispatchActions_WhenIsInsideMiddlewareChange() { var mockMiddleware = MockMiddlewareFactory.Create(); var subject = new Store(BrowserInteropStub); subject.AddMiddleware(mockMiddleware.Object); BrowserInteropStub._TriggerPageLoaded(); var testAction = new TestAction(); using (subject.BeginInternalMiddlewareChange()) { subject.Dispatch(testAction); } mockMiddleware.Verify(x => x.MayDispatchAction(testAction), Times.Never); }
public void DoesNotSendActionToFeatures_WhenMiddlewareForbidsIt() { var testAction = new TestAction(); var mockFeature = MockFeatureFactory.Create(); var mockMiddleware = MockMiddlewareFactory.Create(); mockMiddleware .Setup(x => x.MayDispatchAction(testAction)) .Returns(false); var subject = new Store(StoreInitializer); subject.Initialize(); StoreInitializer.Complete(); subject.Dispatch(testAction); mockFeature .Verify(x => x.ReceiveDispatchNotificationFromStore(testAction), Times.Never); }
public void DoesNotDispatchActions_WhenIsInsideMiddlewareChange() { var mockMiddleware = MockMiddlewareFactory.Create(); var subject = new Store(StoreInitializer); subject.Initialize(); subject.AddMiddleware(mockMiddleware.Object); StoreInitializer.Complete(); var testAction = new TestAction(); using (subject.BeginInternalMiddlewareChange()) { subject.Dispatch(testAction); } mockMiddleware.Verify(x => x.MayDispatchAction(testAction), Times.Never); }