public async void Can_only_mock_root_flow(bool isMocked) { // Arrange var(mediator, _) = GetMediator <MockActivityViaFlowRFlowRequest>(); var flowContext = new FlowContext(null, null); if (isMocked) { flowContext .MockActivity <CanMockOnlyRootSetValueRequest, CanMockOnlyRootSetValueResponse>( request => new CanMockOnlyRootSetValueResponse { Value = false }); } // Act var response = await mediator.Send(new CanMockOnlyRootFlowRequest { FlowContext = flowContext }); // Assert Assert.True(response.Value, "response.Value"); }
public static FlowContext MockCheckEligibility(this FlowContext flowContext, bool isEligible) { flowContext.MockActivity <CheckEligibility, CheckEligibility.Response>( req => new CheckEligibility.Response { IsEligible = isEligible }); return(flowContext); }
public static FlowContext MockIdentityCheck(this FlowContext flowContext, IdentityCheckResult identityCheckResult) { flowContext.MockActivity <CheckIdentity, CheckIdentity.Response>( req => new CheckIdentity.Response { IdentityCheckResult = identityCheckResult }); return(flowContext); }
public static FlowContext MockSendEmail(this FlowContext flowContext, List <string> actualTemplateNames = null) { flowContext.MockActivity <SendEmail, SendEmail.Response>(req => { actualTemplateNames?.Add(req.TemplateName); return(new SendEmail.Response()); }); return(flowContext); }
public static FlowContext MockCheckAffordability(this FlowContext flowContext, AffordabilityRating affordabilityRating) { flowContext.MockActivity <CheckAffordability, CheckAffordability.Response>( req => new CheckAffordability.Response { AffordabilityRating = affordabilityRating }); return(flowContext); }
public static FlowContext MockRaiseLoanDecisionReferredEvent(this FlowContext flowContext, bool?[] isEventRaised = null) { flowContext.MockActivity <RaiseLoanDecisionReferredEvent, RaiseLoanDecisionReferredEvent.Response>(req => { if (isEventRaised != null) { isEventRaised[0] = true; } return(new RaiseLoanDecisionReferredEvent.Response()); }); return(flowContext); }
public static FlowContext MockCreateLoanDecision(this FlowContext flowContext, LoanDecisionResult?[] actualDecisionOverallResult = null) { flowContext.MockActivity <CreateLoanDecision, CreateLoanDecision.Response>(req => { if (actualDecisionOverallResult != null) { actualDecisionOverallResult[0] = req.LoanDecision.Result; } return(new CreateLoanDecision.Response { LoanDecisionId = Guid.NewGuid().ToString() }); }); return(flowContext); }
public async void Can_mock_activity_by_request_type_and_name(bool isMocked, string stepName, string expectedValue1, string expectedValue2, string expectedValue3) { var(mediator, _) = GetMediator <MockActivityViaFlowRFlowRequest>(); var flowContext = new FlowContext(null, null); if (isMocked) { flowContext .MockActivity <SetStringFlowValueRequest, SetStringFlowValueResponse>( stepName, request => new SetStringFlowValueResponse { Output = "Z" }); } var response = await mediator.Send(new MockActivityViaFlowRFlowRequest { FlowContext = flowContext }); Assert.Equal(expectedValue1, response.Value1); Assert.Equal(expectedValue2, response.Value2); Assert.Equal(expectedValue3, response.Value3); }
public static FlowContext MockQuestionActivity(this FlowContext flowContext, string stepName, string answer) => flowContext.MockActivity <QuestionRequest, QuestionResponse>(stepName, req => new QuestionResponse { Answer = answer });
public static FlowContext MockGuessActivity(this FlowContext flowContext) => flowContext.MockActivity <GuessRequest, GuessResponse>(req => new GuessResponse { Guess = req.Guess });