public void Setup() { _now = DateTime.UtcNow; _logger = new Mock <ILog>(); _currentDateTime = new Mock <ICurrentDateTime>(); _forecastingService = new Mock <IDasForecastingService>(); _levyService = new Mock <IDasLevyService>(); _validator = new Mock <IValidator <GetAccountFinanceOverviewQuery> >(); _query = new GetAccountFinanceOverviewQuery { AccountId = ExpectedAccountId }; _expiringFunds = new ExpiringAccountFunds { AccountId = ExpectedAccountId, ExpiryAmounts = new List <ExpiringFunds> { new ExpiringFunds { PayrollDate = new DateTime(2019, 4, 6), Amount = 3000 }, new ExpiringFunds { PayrollDate = new DateTime(2019, 5, 6), Amount = 4000 }, new ExpiringFunds { PayrollDate = new DateTime(2019, 3, 6), Amount = 2000 } } }; _projectedCalculation = new ProjectedCalculation { AccountId = ExpectedAccountId, FundsIn = ExpectedFundsIn, FundsOut = ExpectedFundsOut, NumberOfMonths = 12 }; _handler = new GetAccountFinanceOverviewQueryHandler( _currentDateTime.Object, _forecastingService.Object, _levyService.Object, _validator.Object, _logger.Object); _currentDateTime.Setup(d => d.Now).Returns(_now); _forecastingService.Setup(s => s.GetExpiringAccountFunds(ExpectedAccountId)).ReturnsAsync(_expiringFunds); _forecastingService.Setup(s => s.GetProjectedCalculations(ExpectedAccountId)).ReturnsAsync(_projectedCalculation); _levyService.Setup(s => s.GetAccountBalance(ExpectedAccountId)).ReturnsAsync(ExpectedCurrentFunds); _validator.Setup(v => v.ValidateAsync(_query)) .ReturnsAsync(new ValidationResult { ValidationDictionary = new Dictionary <string, string>() }); }
public void Setup() { _httpClient = new Mock <IHttpClientWrapper>(); _azureAdAuthService = new Mock <IAzureAdAuthenticationService>(); _apiClientConfiguration = new ForecastingApiClientConfiguration { ApiBaseUrl = "testUrl", ClientId = "clientId", ClientSecret = "secret", IdentifierUri = "test", Tenant = "tenant" }; _expectedProjectedCalculations = new ProjectedCalculation { AccountId = ExpectedAccountId, ProjectionGenerationDate = DateTime.Now, FundsIn = ExpectedFundsIn, FundsOut = ExpectedFundsOut, NumberOfMonths = 12 }; _logger = new Mock <ILog>(); _service = new EmployerFinance.Services.DasForecastingService(_httpClient.Object, _azureAdAuthService.Object, _apiClientConfiguration, _logger.Object); _httpClient.Setup(c => c.Get <ProjectedCalculation>(It.IsAny <string>(), It.IsAny <string>())) .ReturnsAsync(_expectedProjectedCalculations); _azureAdAuthService.Setup(s => s.GetAuthenticationResult( _apiClientConfiguration.ClientId, _apiClientConfiguration.ClientSecret, _apiClientConfiguration.IdentifierUri, _apiClientConfiguration.Tenant)).ReturnsAsync(AccessToken); }