public async Task Then_UpdateVendorRegistrationCaseStatusForAccountCommand_is_published_for_each_matching_account() { // Arrange var command = new UpdateVendorRegistrationCaseStatusCommand(_fixture.Create <string>(), _fixture.Create <string>(), _fixture.Create <string>(), _fixture.Create <DateTime>()); var accounts = _fixture.CreateMany <Account>().ToList(); _mockDomainRepository.Setup(x => x.GetByHashedLegalEntityId(command.HashedLegalEntityId)) .ReturnsAsync(accounts); // Act await _sut.Handle(command, CancellationToken.None); // Assert foreach (var account in accounts) { _mockCommandPublisher.Verify(x => x.Publish(It.Is <UpdateVendorRegistrationCaseStatusForAccountCommand>( c => c.AccountId == account.Id && c.CaseId == command.CaseId && c.HashedLegalEntityId == command.HashedLegalEntityId && c.Status == command.Status && c.LastUpdatedDate == command.CaseStatusLastUpdatedDate ), CancellationToken.None), Times.Once()); } }
public async Task Then_The_legal_entity_is_updated_with_the_supplied_case_status( [Frozen] Mock <IEmployerIncentivesService> incentivesService, UpdateVendorRegistrationCaseStatusCommandHandler handler, UpdateVendorRegistrationCaseStatusCommand command) { var legalEntity = new Fixture().Create <AccountLegalEntity>(); legalEntity.AccountId = command.AccountId; legalEntity.AccountLegalEntityId = command.AccountLegalEntityId; incentivesService.Setup(x => x.GetLegalEntity(command.AccountId, command.AccountLegalEntityId)) .ReturnsAsync(legalEntity); await handler.Handle(command, CancellationToken.None); incentivesService.Verify(x => x.GetLegalEntity(command.AccountId, command.AccountLegalEntityId), Times.Once); incentivesService.Verify(x => x.UpdateVendorRegistrationCaseStatus(It.Is <UpdateVendorRegistrationCaseStatusRequest> (y => y.HashedLegalEntityId == legalEntity.HashedLegalEntityId && y.Status == command.VrfCaseStatus)), Times.Once); }