public async Task Then_the_earnings_calculated_flag_is_updated_for_matching_apprenticeship() { //Arrange var incentiveApplication = _fixture.Create <IncentiveApplication>(); var firstApprenticeship = incentiveApplication.Apprenticeships.First(); firstApprenticeship.Id = _apprenticeshipIncentiveId; var apprenticeshipModel = _fixture.Build <ApprenticeshipModel>().With(x => x.Id, _apprenticeshipIncentiveId) .Without(x => x.EarningsCalculated).Create(); var apprenticeshipModel2 = _fixture.Create <ApprenticeshipModel>(); var domainIncentiveApplication = _fixture.Create <Domain.IncentiveApplications.IncentiveApplication>(); domainIncentiveApplication.SetApprenticeships(new List <Apprenticeship> { Apprenticeship.Create(apprenticeshipModel), Apprenticeship.Create(apprenticeshipModel2) }); var command = new CompleteEarningsCalculationCommand(incentiveApplication.AccountId, firstApprenticeship.Id, firstApprenticeship.ApprenticeshipId, _apprenticeshipIncentiveId); _mockQueryRepository.Setup(x => x.Get(It.IsAny <Expression <Func <Data.Models.IncentiveApplicationApprenticeship, bool> > >())) .ReturnsAsync(firstApprenticeship); _mockIncentiveApplicationDomainRepository.Setup(x => x .Find(firstApprenticeship.IncentiveApplicationId)) .ReturnsAsync(domainIncentiveApplication); // Act await _sut.Handle(command); domainIncentiveApplication.Apprenticeships.First().EarningsCalculated.Should().BeTrue(); domainIncentiveApplication.Apprenticeships.Last().EarningsCalculated.Should().BeFalse(); }
public Task Handle(EarningsCalculated @event, CancellationToken cancellationToken = default) { var command = new CompleteEarningsCalculationCommand( @event.AccountId, @event.ApplicationApprenticeshipId, @event.ApprenticeshipId, @event.ApprenticeshipIncentiveId); return(_commandPublisher.Publish(command)); }
public async Task WhenTheEarningCalculationCompletes() { var completeEarningsCalcCommand = new CompleteEarningsCalculationCommand( _apprenticeshipIncentive.AccountId, _apprenticeshipIncentive.IncentiveApplicationApprenticeshipId, _apprenticeshipIncentive.ApprenticeshipId, _apprenticeshipIncentive.Id); await _testContext.WaitFor <ICommand>(async (cancellationToken) => await _testContext.MessageBus.Send(completeEarningsCalcCommand)); }
public async Task HandleCommand([NServiceBusTrigger(Endpoint = QueueNames.CompleteEarningsCalculation)] CompleteEarningsCalculationCommand command) { await _commandService.Dispatch(command); }