public ProcessLevyDeclarationsCommandHandlerTestsFixture() { Fixture = new Fixture(); Now = DateTime.UtcNow; UnitOfWorkContext = new UnitOfWorkContext(); EmployerReferenceNumbers = new List <string> { "AAA111", "BBB222", "CCC333" }; Accounts = new List <Account> { Fixture.Create <Account>(), Fixture.Create <Account>() }; AccountPayeSchemes = new List <AccountPayeScheme> { new AccountPayeScheme(Accounts[0], EmployerReferenceNumbers[0], Now).Set(aps => aps.Id, 1), new AccountPayeScheme(Accounts[0], EmployerReferenceNumbers[1], Now).Set(aps => aps.Id, 2), new AccountPayeScheme(Accounts[1], EmployerReferenceNumbers[2], Now).Set(aps => aps.Id, 3) }; Command = new ProcessLevyDeclarationsCommand(Now); Db = new EmployerFinanceDbContext(new DbContextOptionsBuilder <EmployerFinanceDbContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options); Db.AccountPayeSchemes.AddRange(AccountPayeSchemes); Db.SaveChanges(); Handler = new ProcessLevyDeclarationsCommandHandler(Db); }
public Task Run([TimerTrigger("0 0 15 20 * *")] TimerInfo timer, ILogger logger) { var now = _dateTimeService.UtcNow; var month = new DateTime(now.Year, now.Month, 6, 0, 0, 0, 0, DateTimeKind.Utc); var payrollPeriod = month.AddMonths(-1); var command = new ProcessLevyDeclarationsCommand(payrollPeriod); var task = _messageSession.Send(command); logger.LogInformation($"Sent '{nameof(ProcessLevyDeclarationsCommand)}' with '{nameof(ProcessLevyDeclarationsCommand.PayrollPeriod)}' value '{command.PayrollPeriod:MM yyyy}'"); return(task); }