public void Arrange() { _mockCommandService = new Mock <ICommandService>(); _fixture = new Fixture(); _command = _fixture.Create <UpdateVendorRegistrationCaseStatusForAccountCommand>(); _sut = new HandleUpdateVendorRegistrationCaseStatusForAccountCommand(_mockCommandService.Object); }
public async Task Then_event_BankDetailsApprovedForLegalEntity_is_raised_when_status_is_completed() { // Arrange var account = _fixture.Create <Account>(); var caseCompletedCommand = new UpdateVendorRegistrationCaseStatusForAccountCommand(account.Id, LegalEntityToBeUpdatedId, _fixture.Create <string>(), LegalEntityVrfCaseStatus.Completed, _fixture.Create <DateTime>()); var legalEntityToBeUpdated = LegalEntity.New(123, _fixture.Create <string>(), LegalEntityToBeUpdatedId); account.AddLegalEntity(1, legalEntityToBeUpdated); account.AddLegalEntity(2, _fixture.Create <LegalEntity>()); account.AddLegalEntity(3, _fixture.Create <LegalEntity>()); _mockDomainRepository.Setup(x => x.Find(caseCompletedCommand.AccountId)).ReturnsAsync(account); // Act await _sut.Handle(caseCompletedCommand); // Assert var events = account.FlushEvents().ToList(); events.Count.Should().Be(1); events[0].GetType().Should().Be <BankDetailsApprovedForLegalEntity>(); ((BankDetailsApprovedForLegalEntity)events[0]).HashedLegalEntityId.Should().Be(LegalEntityToBeUpdatedId); }
public async Task Then_VRF_details_for_given_legal_entity_are_not_updated_if_status_is_completed() { // Arrange var account = _fixture.Create <Account>(); var caseCompletedCommand = new UpdateVendorRegistrationCaseStatusForAccountCommand(account.Id, LegalEntityToBeUpdatedId, _fixture.Create <string>(), "case request completed", _fixture.Create <DateTime>()); var legalEntityToBeUpdated = LegalEntity.New(123, _fixture.Create <string>(), LegalEntityToBeUpdatedId); account.AddLegalEntity(1, legalEntityToBeUpdated); account.AddLegalEntity(2, _fixture.Create <LegalEntity>()); account.AddLegalEntity(3, _fixture.Create <LegalEntity>()); // Act _mockDomainRepository.Setup(x => x.Find(caseCompletedCommand.AccountId)).ReturnsAsync(account); await _sut.Handle(caseCompletedCommand); var command2 = new UpdateVendorRegistrationCaseStatusForAccountCommand(account.Id, LegalEntityToBeUpdatedId, caseCompletedCommand.CaseId, "New Status", _fixture.Create <DateTime>()); // Act await _sut.Handle(command2); // Assert var legalEntities = account.LegalEntities.Where( e => e.HashedLegalEntityId == command2.HashedLegalEntityId).ToList(); legalEntities.Should().NotBeEmpty(); foreach (var legalEntity in legalEntities) { legalEntity.VrfCaseId.Should().Be(caseCompletedCommand.CaseId); legalEntity.VrfCaseStatus.Should().Be(caseCompletedCommand.Status); legalEntity.VrfCaseStatusLastUpdatedDateTime.Should().Be(caseCompletedCommand.LastUpdatedDate); } }
public async Task Then_VRF_details_for_given_legal_entity_are_updated() { // Arrange var account = _fixture.Create <Account>(); var command = new UpdateVendorRegistrationCaseStatusForAccountCommand( account.Id, LegalEntityToBeUpdatedId, _fixture.Create <string>(), _fixture.Create <string>(), _fixture.Create <DateTime>()); var legalEntityToBeUpdated = LegalEntity.New(123, _fixture.Create <string>(), LegalEntityToBeUpdatedId); account.AddLegalEntity(1, legalEntityToBeUpdated); account.AddLegalEntity(2, _fixture.Create <LegalEntity>()); account.AddLegalEntity(3, _fixture.Create <LegalEntity>()); account.AddLegalEntity(4, legalEntityToBeUpdated); _mockDomainRepository.Setup(x => x.Find(command.AccountId)).ReturnsAsync(account); // Act await _sut.Handle(command); // Assert var updatedLegalEntities = account.LegalEntities.Where( e => e.HashedLegalEntityId == command.HashedLegalEntityId && e.VrfCaseStatus != "Completed").ToList(); updatedLegalEntities.Should().HaveCount(2); foreach (var legalEntity in updatedLegalEntities) { legalEntity.VrfCaseId.Should().Be(command.CaseId); legalEntity.VrfCaseStatus.Should().Be(command.Status); legalEntity.VrfCaseStatusLastUpdatedDateTime.Should().Be(command.LastUpdatedDate); } _mockDomainRepository.Verify(m => m.Save(account), Times.Once); _mockDomainRepository.VerifyAll(); }
public async Task HandleCommand([NServiceBusTrigger(Endpoint = QueueNames.UpdateVendorRegistrationCaseStatus)] UpdateVendorRegistrationCaseStatusForAccountCommand command) { await _commandService.Dispatch(command); }