/// <summary> /// Adds results of command execution to context. /// </summary> /// <param name="command">Executed command.</param> /// <param name="integrationEvent">Expected event.</param> /// <param name="result">Execution result.</param> /// <returns>Updated execution context.</returns> public TestFlowExecutionContext Update(Command command, IntegrationEvent integrationEvent, IExecutionResult result) { return(new TestFlowExecutionContext( Host, AggregateVersions, ExecutedCommands.Add(command), ExpectedEvents.Add(integrationEvent), ExecutionResults.Add(result))); }
public EventFlowValidator <TRequestContext> AddResultValidation(Action <TRequestContext> resultValidation) { // Add the expected event ExpectedEvents.Add(new ExpectedEvent { EventType = EventTypes.Result, ParamType = typeof(TRequestContext), Validator = resultValidation }); return(this); }
public EventFlowValidator <TRequestContext> AddSimpleErrorValidation(Action <string, int> paramValidation) { // Put together a validator that ensures a null data // Add the expected result ExpectedEvents.Add(new ExpectedEvent { EventType = EventTypes.Error, ParamType = typeof(Error), Validator = (Action <Error>)(e => { Assert.NotNull(e); paramValidation(e.Message, e.Code); }) }); return(this); }
public EventFlowValidator <TRequestContext> AddEventValidation <TParams>(EventType <TParams> expectedEvent, Action <TParams> paramValidation, Action <TParams> userCallback = null) { ExpectedEvents.Add(new ExpectedEvent { EventType = EventTypes.Event, ParamType = typeof(TParams), Validator = paramValidation }); Context.Setup(rc => rc.SendEvent(expectedEvent, It.IsAny <TParams>())) .Callback <EventType <TParams>, TParams>((et, p) => { ReceivedEvents.Add(new ReceivedEvent { EventObject = p, EventType = EventTypes.Event }); userCallback?.DynamicInvoke(p); }) .Returns(Task.FromResult(0)); return(this); }