Ejemplo n.º 1
0
            public void NotifiesFeatures()
            {
                var mockFeature = MockFeatureFactory.Create();
                var subject     = new Store(BrowserInteropStub);

                subject.AddFeature(mockFeature.Object);

                var testAction = new TestAction();

                BrowserInteropStub._TriggerPageLoaded();
                subject.Dispatch(testAction);

                mockFeature
                .Verify(x => x.ReceiveDispatchNotificationFromStore(testAction));
            }
Ejemplo n.º 2
0
        public async Task WhenCalled_ThenPassesActionOnToAllFeatures()
        {
            var mockFeature = MockFeatureFactory.Create();
            var subject     = new TestStore();

            subject.AddFeature(mockFeature.Object);
            await subject.InitializeAsync();

            var testAction = new TestAction();

            subject.Dispatch(testAction);

            mockFeature
            .Verify(x => x.ReceiveDispatchNotificationFromStore(testAction));
        }
Ejemplo n.º 3
0
            public void NotifiesFeatures()
            {
                var mockFeature = MockFeatureFactory.Create();
                var subject     = new Store(StoreInitializer);

                subject.AddFeature(mockFeature.Object);
                subject.Initialize();

                var testAction = new TestAction();

                StoreInitializer.Complete();
                subject.Dispatch(testAction);

                mockFeature
                .Verify(x => x.ReceiveDispatchNotificationFromStore(testAction));
            }
Ejemplo n.º 4
0
            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);
            }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
            public void DispatchesTasksFromEffect()
            {
                var mockFeature   = MockFeatureFactory.Create();
                var actionToEmit1 = new TestActionFromEffect1();
                var actionToEmit2 = new TestActionFromEffect2();
                var actionsToEmit = new IAction[] { actionToEmit1, actionToEmit2 };
                var subject       = new Store(BrowserInteropStub);

                subject.AddFeature(mockFeature.Object);
                subject.AddEffect(new EffectThatEmitsActions <TestAction>(actionsToEmit));

                BrowserInteropStub._TriggerPageLoaded();
                subject.Dispatch(new TestAction());

                mockFeature
                .Verify(x => x.ReceiveDispatchNotificationFromStore(actionToEmit1), Times.Once);
                mockFeature
                .Verify(x => x.ReceiveDispatchNotificationFromStore(actionToEmit2), Times.Once);
            }
Ejemplo n.º 7
0
        public async Task WhenFinished_ThenDispatchesTasksFromRegisteredEffects()
        {
            var mockFeature   = MockFeatureFactory.Create();
            var actionToEmit1 = new TestActionFromEffect1();
            var actionToEmit2 = new TestActionFromEffect2();
            var actionsToEmit = new object[] { actionToEmit1, actionToEmit2 };
            var subject       = new TestStore();
            await subject.InitializeAsync();

            subject.AddFeature(mockFeature.Object);
            subject.AddEffect(new EffectThatEmitsActions <TestAction>(actionsToEmit));

            subject.Dispatch(new TestAction());

            mockFeature
            .Verify(x => x.ReceiveDispatchNotificationFromStore(actionToEmit1), Times.Once);
            mockFeature
            .Verify(x => x.ReceiveDispatchNotificationFromStore(actionToEmit2), Times.Once);
        }
Ejemplo n.º 8
0
            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);
            }
Ejemplo n.º 9
0
            public void DispatchesTasksFromEffect()
            {
                var mockFeature   = MockFeatureFactory.Create();
                var actionToEmit1 = new TestActionFromEffect1();
                var actionToEmit2 = new TestActionFromEffect2();
                var actionsToEmit = new object[] { actionToEmit1, actionToEmit2 };
                var subject       = new Store(StoreInitializer);

                subject.Initialize();
                subject.AddFeature(mockFeature.Object);
                subject.AddEffect(new EffectThatEmitsActions <TestAction>(actionsToEmit));

                StoreInitializer.Complete();
                subject.Dispatch(new TestAction());

                mockFeature
                .Verify(x => x.ReceiveDispatchNotificationFromStore(actionToEmit1), Times.Once);
                mockFeature
                .Verify(x => x.ReceiveDispatchNotificationFromStore(actionToEmit2), Times.Once);
            }