public void Arrange() { _mediator = new Mock <IMediator>(); _query = new GetLegalEntityQuery(); _legalEntity = new LegalEntityViewModel(); _response = new GetLegalEntityResponse { LegalEntity = _legalEntity }; _mediator.Setup(m => m.SendAsync(_query)).ReturnsAsync(_response); _controller = new LegalEntitiesController(null, _mediator.Object); }
public async Task Then_Returns_Legal_Entity( GetLegalEntityQuery query, AccountLegalEntity legalEntity, [Frozen] Mock <IApiClient> mockApiClient, GetLegalEntityQueryHandler handler) { mockApiClient .Setup(client => client.Get <AccountLegalEntity>(It.IsAny <GetAccountLegalEntityRequest>())) .ReturnsAsync(legalEntity); var result = await handler.Handle(query, CancellationToken.None); result.AccountLegalEntity.Should().Be(legalEntity); }
public async Task Then_Gets_Legal_Entity( GetLegalEntityQuery query, AccountLegalEntity legalEntity, [Frozen] Mock <IApiClient> mockApiClient, GetLegalEntityQueryHandler handler) { mockApiClient .Setup(client => client.Get <AccountLegalEntity>(It.IsAny <GetAccountLegalEntityRequest>())) .ReturnsAsync(legalEntity); await handler.Handle(query, CancellationToken.None); mockApiClient.Verify(client => client.Get <AccountLegalEntity>(It.Is <GetAccountLegalEntityRequest>(r => r.Id.Equals(query.Id))), Times.Once); }
public async Task Then_The_AccountLegalEntity_Is_Returned( GetLegalEntityQuery query, AccountLegalEntity response, [Frozen] Mock <ILegalEntitiesService> legalEntitiesService, GetLegalEntityHandler handler ) { legalEntitiesService.Setup(x => x.GetLegalEntity(query.AccountId, query.AccountLegalEntityId)).ReturnsAsync(response); var actual = await handler.Handle(query, CancellationToken.None); actual.AccountLegalEntity.Should().BeEquivalentTo(response); }
public async Task Then_Hashes_The_Id( GetLegalEntityQuery query, AccountLegalEntity legalEntity, [Frozen] Mock <IApiClient> mockApiClient, [Frozen] Mock <IEncodingService> encodingService, GetLegalEntityQueryHandler handler) { mockApiClient .Setup(client => client.Get <AccountLegalEntity>(It.IsAny <GetAccountLegalEntityRequest>())) .ReturnsAsync(legalEntity); await handler.Handle(query, CancellationToken.None); encodingService.Verify(service => service.Encode(legalEntity.AccountLegalEntityId, EncodingType.PublicAccountLegalEntityId), Times.Once); }
public async Task Then_Uses_correct_Api_Base_Url( GetLegalEntityQuery query, AccountLegalEntity legalEntity, [Frozen] Mock <IApiClient> mockApiClient, [Frozen] Mock <IOptions <ReservationsApiConfiguration> > mockOptions, [Frozen] Mock <IEncodingService> encodingService, [Frozen] ReservationsApiConfiguration configuration, GetLegalEntityQueryHandler handler) { mockOptions.Setup(c => c.Value).Returns(configuration); mockApiClient .Setup(client => client.Get <AccountLegalEntity>(It.IsAny <GetAccountLegalEntityRequest>())) .ReturnsAsync(legalEntity); await handler.Handle(query, CancellationToken.None); mockApiClient.Verify(client => client.Get <AccountLegalEntity>(It.Is <GetAccountLegalEntityRequest>(r => r.BaseUrl.Equals(configuration.Url))), Times.Once); }
public async Task <IHttpActionResult> GetLegalEntity([FromUri] GetLegalEntityQuery query) { var response = await _mediator.SendAsync(query); return(Ok(response.LegalEntity)); }