public async Task ThenTheServiceShouldBeNotified() { //Arrange _commintmentService.Setup(x => x.GetEmployerCommitments(It.IsAny <long>())) .ReturnsAsync(new List <Cohort> { new Cohort() }); //Act await _handler.Handle(_command); //Assert _eventPublisher.Events.Should().HaveCount(1); var message = _eventPublisher.Events.First().As <SignedAgreementEvent>(); message.AccountId.Should().Be(AccountId); message.AgreementId.Should().Be(AgreementId); message.OrganisationName.Should().Be(OrganisationName); message.AccountLegalEntityId.Should().Be(AccountLegalEntityId); message.LegalEntityId.Should().Be(LegalEntityId); message.CohortCreated.Should().BeTrue(); message.UserName.Should().Be(_owner.FullName()); message.UserRef.Should().Be(_owner.UserRef); message.AgreementType.Should().Be(AgreementType); }
private async Task PublihAgreementSignedMessage(EmployerAgreementView agreement, MembershipView owner, string correlationId) { var commitments = await _commitmentService.GetEmployerCommitments(agreement.AccountId); var accountHasCommitments = commitments?.Any() ?? false; await PublishAgreementSignedMessage(agreement.AccountId, agreement.AccountLegalEntityId, agreement.LegalEntityId, agreement.LegalEntityName, agreement.Id, accountHasCommitments, owner.FullName(), owner.UserRef, agreement.AgreementType, agreement.VersionNumber, correlationId); }
private bool B(AddedLegalEntityEvent e) { return(e.AccountId.Equals(_owner.AccountId) && e.AgreementId.Equals(_agreementView.Id) && e.LegalEntityId.Equals(_agreementView.LegalEntityId) && e.AccountLegalEntityId.Equals(_agreementView.AccountLegalEntityId) && e.AccountLegalEntityPublicHashedId.Equals(ExpectedAccountLegalEntityPublicHashString) && e.OrganisationName.Equals(Command.Name) && e.UserName.Equals(_owner.FullName()) && e.UserRef.Equals(_owner.UserRef) && e.OrganisationReferenceNumber.Equals(_agreementView.LegalEntityCode) && e.OrganisationAddress.Equals(_agreementView.LegalEntityAddress) && e.OrganisationType.ToString().Equals(_agreementView.LegalEntitySource.ToString())); }
public async Task ThenAddedLegalEntityEventIsPublished() { await _commandHandler.Handle(_command); _eventPublisher.Verify(ep => ep.Publish(It.Is <AddedLegalEntityEvent>(e => e.AccountId.Equals(_owner.AccountId) && e.AgreementId.Equals(_agreementView.Id) && e.LegalEntityId.Equals(_agreementView.LegalEntityId) && e.AccountLegalEntityId.Equals(_agreementView.AccountLegalEntityId) && e.AccountLegalEntityPublicHashedId.Equals(ExpectedAccountLegalEntityPublicHashString) && e.OrganisationName.Equals(_command.Name) && e.UserName.Equals(_owner.FullName()) && e.UserRef.Equals(Guid.Parse(_owner.UserRef)) && e.OrganisationReferenceNumber.Equals(_agreementView.LegalEntityCode) && e.OrganisationAddress.Equals(_agreementView.LegalEntityAddress) && e.OrganisationType.ToString().Equals(_agreementView.LegalEntitySource.ToString())))); }