Ejemplo n.º 1
0
        public void WhenFeatureWithSameNameAlreadyExists_ThenThrowsArgumentException()
        {
            const string featureName = "1234";
            var          mockFeature = new Mock <IFeature>();

            mockFeature
            .Setup(x => x.GetName())
            .Returns(featureName);

            var subject = new TestStore();

            subject.AddFeature(mockFeature.Object);

            Assert.Throws <ArgumentException>(() =>
            {
                subject.AddFeature(mockFeature.Object);
            });
        }
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 WhenFeatureNameIsUnique_ThenAddsFeatureToFeaturesDictionary()
        {
            const string featureName = "123";
            var          mockFeature = new Mock <IFeature>();

            mockFeature
            .Setup(x => x.GetName())
            .Returns(featureName);

            var subject = new TestStore();

            subject.AddFeature(mockFeature.Object);

            Assert.Same(mockFeature.Object, subject.Features[featureName]);
        }
Ejemplo n.º 4
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);
        }