public void TestTransfrom() { LogicImpl logic = new LogicImpl(); Moq.Mock <IStore <AppState> > store = new Moq.Mock <IStore <AppState> >(); logic.OnTransform = (s, a) => Task.FromResult(a + "World"); var result = ((ILogic <AppState, string>)logic).PreProcess(store.Object, "Hello"); Assert.AreEqual("HelloWorld", result.Result.Action); }
public void TestValidationSuccess() { LogicImpl logic = new LogicImpl(); Moq.Mock <IStore <AppState> > store = new Moq.Mock <IStore <AppState> >(); store.Setup(s => s.Dispatch(It.IsAny <ValidationException>())); logic.OnValidation = (s, a, d) => Task.FromResult(ValidationResult.Success()); var result = ((ILogic <AppState, string>)logic).PreProcess(store.Object, "Hello"); Assert.AreEqual(true, result.Result.ContinueToNextStep); store.Verify(s => s.Dispatch(It.IsAny <ValidationException>()), Times.Never()); }
public void TestValidationFailure() { LogicImpl logic = new LogicImpl(); Moq.Mock <IStore <AppState> > store = new Moq.Mock <IStore <AppState> >(); store.Setup(s => s.Dispatch(It.IsAny <ValidationException>())); logic.OnValidation = (s, a, d) => Task.FromResult(ValidationResult.Failure(new ValidationException("", new[] { new ValidationDetails("", "") }))); var result = ((ILogic <AppState, string>)logic).PreProcess(store.Object, "Hello"); Assert.AreEqual(false, result.Result.ContinueToNextStep); store.Verify(s => s.Dispatch(It.IsAny <ValidationException>()), Times.Once()); }