public async Task ThenTheLegalEntityIsReturned() { var hashedAccountId = "ABC123"; var legalEntityId = 123; var legalEntityResponse = new GetLegalEntityByIdResponse { LegalEntity = new LegalEntityView { Id = legalEntityId, Name = "Test", Code = "ABC123", Status = "active", DateOfInception = DateTime.Now.AddYears(-3), Address = "Some address", Source = "Companies House" } }; Mediator.Setup(x => x.SendAsync(It.Is <GetLegalEntityByIdQuery>(q => q.Id == legalEntityId))).ReturnsAsync(legalEntityResponse); var response = await Controller.GetLegalEntity(hashedAccountId, legalEntityId); Assert.IsNotNull(response); Assert.IsInstanceOf <OkNegotiatedContentResult <LegalEntityViewModel> >(response); var model = response as OkNegotiatedContentResult <LegalEntityViewModel>; model?.Content.Should().NotBeNull(); model.Content.ShouldBeEquivalentTo(legalEntityResponse.LegalEntity, options => options.Excluding(x => x.DasAccountId).Excluding(x => x.LegalEntityId)); model.Content.DasAccountId.Should().Be(hashedAccountId); model.Content.LegalEntityId.Should().Be(legalEntityId); }
public async Task AndTheLegalEntityDoesNotExistThenItIsNotReturned() { var hashedAccountId = "ABC123"; var legalEntityId = 123; var legalEntityResponse = new GetLegalEntityByIdResponse { LegalEntity = null }; Mediator.Setup(x => x.SendAsync(It.Is <GetLegalEntityByIdQuery>(q => q.Id == legalEntityId))).ReturnsAsync(legalEntityResponse); var response = await Controller.GetLegalEntity(hashedAccountId, legalEntityId); Assert.IsNotNull(response); Assert.IsInstanceOf <NotFoundResult>(response); }
private LegalEntityViewModel ConvertLegalEntityToViewModel(string hashedAccountId, GetLegalEntityByIdResponse legalEntityResult) { var legalEntityViewModel = new LegalEntityViewModel { DasAccountId = hashedAccountId, DateOfInception = legalEntityResult.LegalEntity.DateOfInception, LegalEntityId = legalEntityResult.LegalEntity.Id, Name = legalEntityResult.LegalEntity.Name, Source = legalEntityResult.LegalEntity.Source, PublicSectorDataSource = legalEntityResult.LegalEntity.PublicSectorDataSource, Address = legalEntityResult.LegalEntity.Address, Code = legalEntityResult.LegalEntity.Code, Status = legalEntityResult.LegalEntity.Status, Sector = legalEntityResult.LegalEntity.Sector, AgreementStatus = (EmployerAgreementStatus)((int)legalEntityResult.LegalEntity.AgreementStatus), AgreementSignedByName = legalEntityResult.LegalEntity.AgreementSignedByName, AgreementSignedDate = legalEntityResult.LegalEntity.AgreementSignedDate }; return(legalEntityViewModel); }