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); }); }
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)); }
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]); }
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); }