public void Setup()
        {
            _fixture = new Fixture();
            _mockWithdrawalService = new Mock <IWithdrawalService>();

            _mockWithdrawalService
            .Setup(m => m.Withdraw(It.IsAny <WithdrawRequest>()))
            .Returns(Task.FromResult <IActionResult>(new OkResult()));

            _sut = new HandleWithdrawalRequest(_mockWithdrawalService.Object);
        }
        public async Task Start()
        {
            var startUp = new Startup();

            var hostBuilder = new HostBuilder()
                              .ConfigureHostConfiguration(a =>
            {
                a.Sources.Clear();
                a.AddInMemoryCollection(_hostConfig);
            })
                              .ConfigureAppConfiguration(a =>
            {
                a.Sources.Clear();
                a.AddInMemoryCollection(_appConfig);
                a.SetBasePath(_testMessageBus.StorageDirectory.FullName);
            })
                              .ConfigureWebJobs(startUp.Configure)
            ;

            _ = hostBuilder.ConfigureServices((s) =>
            {
                s.Configure <Config.EmployerIncentivesApiOptions>(a =>
                {
                    a.ApiBaseUrl      = _testEmployerIncentivesApi.BaseAddress;
                    a.SubscriptionKey = "";
                });

                _ = s.AddNServiceBus(new LoggerFactory().CreateLogger <TestLegalEntitiesFunctions>(),
                                     (o) =>
                {
                    o.EndpointConfiguration = (endpoint) =>
                    {
                        endpoint.UseTransport <LearningTransport>().StorageDirectory(_testMessageBus.StorageDirectory.FullName);
                        return(endpoint);
                    };

                    var hook = _messageHooks.SingleOrDefault(h => h is Hook <MessageContext>) as Hook <MessageContext>;
                    if (hook != null)
                    {
                        o.OnMessageReceived = (message) =>
                        {
                            hook?.OnReceived(message);
                        };
                        o.OnMessageProcessed = (message) =>
                        {
                            hook?.OnProcessed(message);
                        };
                        o.OnMessageErrored = (exception, message) =>
                        {
                            hook?.OnErrored(exception, message);
                        };
                    }
                });
            });

            hostBuilder.UseEnvironment("LOCAL");
            host = await hostBuilder.StartAsync();

            // ideally use the test server but no functions support yet.
            HttpTriggerRefreshLegalEntities = new HandleRefreshLegalEntitiesRequest(host.Services.GetService(typeof(ILegalEntitiesService)) as ILegalEntitiesService);
            TimerTriggerRefreshVendorRegistrationCaseStatus = new RefreshVendorRegistrationCaseStatus(host.Services.GetService(typeof(IVrfCaseRefreshService)) as IVrfCaseRefreshService);
            TimerTriggerEarningsResilienceCheck             = new HandleEarningsResilienceCheck(host.Services.GetService(typeof(IEarningsResilienceCheckService)) as IEarningsResilienceCheckService);
            TimerTriggerBankDetailsRepeatReminderEmails     = new HandleBankDetailsRepeatReminderEmails(host.Services.GetService(typeof(IEmailService)) as IEmailService, host.Services.GetService(typeof(IConfiguration)) as IConfiguration);
            HttpTriggerUpdateCollectionCalendarPeriod       = new HandleUpdateCollectionCalendarPeriod(host.Services.GetService(typeof(ICollectionCalendarService)) as ICollectionCalendarService);
            HttpTriggerHandleWithdrawal    = new HandleWithdrawalRequest(host.Services.GetService(typeof(IWithdrawalService)) as IWithdrawalService);
            HttpTriggerHandlePausePayments = new HandlePausePaymentsRequest(host.Services.GetService(typeof(IPausePaymentsService)) as IPausePaymentsService);

            AzureStorageEmulatorManager.StartStorageEmulator(); // only works if emulator sits here: "C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe"
        }