private static UpdateAffiliationController CreateController(ScenarioOptions scenarioOptions = null) { scenarioOptions = scenarioOptions ?? new ScenarioOptions(); scenarioOptions.MockQueryProcessor = new Mock <IProcessQueries>(MockBehavior.Strict); scenarioOptions.MockCommandHandler = new Mock <IHandleCommands <UpdateMyAffiliationCommand> >(MockBehavior.Strict); var services = new UpdateAffiliationServices(scenarioOptions.MockQueryProcessor.Object, scenarioOptions.MockCommandHandler.Object); var controller = new UpdateAffiliationController(services); var builder = ReuseMock.TestControllerBuilder(); builder.HttpContext.User = null; if (!string.IsNullOrWhiteSpace(scenarioOptions.PrincipalIdentityName)) { var principal = scenarioOptions.PrincipalIdentityName.AsPrincipal(); builder.HttpContext.User = principal; } builder.InitializeController(controller); return(controller); }
private static UpdateAffiliationController CreateController(ScenarioOptions scenarioOptions = null) { scenarioOptions = scenarioOptions ?? new ScenarioOptions(); scenarioOptions.MockQueryProcessor = new Mock<IProcessQueries>(MockBehavior.Strict); scenarioOptions.MockCommandHandler = new Mock<IHandleCommands<UpdateMyAffiliationCommand>>(MockBehavior.Strict); var services = new UpdateAffiliationServices(scenarioOptions.MockQueryProcessor.Object, scenarioOptions.MockCommandHandler.Object); var controller = new UpdateAffiliationController(services); var builder = ReuseMock.TestControllerBuilder(); builder.HttpContext.User = null; if (!string.IsNullOrWhiteSpace(scenarioOptions.PrincipalIdentityName)) { var principal = scenarioOptions.PrincipalIdentityName.AsPrincipal(); builder.HttpContext.User = principal; } builder.InitializeController(controller); return controller; }
public UpdateAffiliationController(UpdateAffiliationServices services) { _services = services; }