public async Task GetNfse_ReturnsDto_When_DataIsValid() { //Arrange this.mockAuth.Setup(x => x.ValidateUser()) .Returns("Basic header"); this.mockClient.Protected().Setup <Task <HttpResponseMessage> >("SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>()) .ReturnsAsync(new HttpResponseMessage() { StatusCode = System.Net.HttpStatusCode.OK, Content = new StringContent("ok") }).Verifiable(); var httpClient = new HttpClient(this.mockClient.Object) { BaseAddress = new Uri(ExpectedUri) }; this.nfseHandler = new NFSEHandler(this.mockAuth.Object); //Act var result = await this.nfseHandler.GetNfse("lote", "nfse"); //assert result.Should().NotBeNull(); result.Should().BeOfType <NFSEDto>(); this.mockClient.Protected().Verify( "SendAsync", Times.Exactly(1), ItExpr.IsAny <CancellationToken>() ); }
public NFSEController(INFSE nfse, INfseRepository repository) { this.nfseHandler = nfse; this.nfseRepository = repository; }
public NFSEHandlerTests() { this.mockClient = new Mock <HttpClientHandler>(); this.mockAuth = new Mock <IAuthentication>(); this.nfseHandler = new NFSEHandler(this.mockAuth.Object); }