public async Task SendEmailAsync_WhenRequestTimeout_ReturnsTimeout() { // Arrange var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Put, httpStatusCode: HttpStatusCode.RequestTimeout); var invoiceClient = new ServiceInvoiceClient(TestHelper.apiKey, mockHttp); // Act var result = await invoiceClient.SendEmailAsync(TestHelper.companyId, TestHelper.invoiceId, CancellationToken.None); // Assert Assert.NotNull(result); Assert.Equal(ResultStatusCode.TimedOut, result.Status); }
public async Task SendEmailAsync_WhenSendInvalidApiKey_ReturnsUnauthorized() { // Arrange var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Put, httpStatusCode: HttpStatusCode.Unauthorized); var invoiceClient = new ServiceInvoiceClient("InvalidApiKey", mockHttp); // Act var result = await invoiceClient.SendEmailAsync(TestHelper.companyId, TestHelper.invoiceId, CancellationToken.None); // Assert Assert.NotNull(result); Assert.Equal(ResultStatusCode.Unauthorized, result.Status); }
public async Task SendEmailAsync_WhenHttpStatusCodeIsUnexpected_ReturnsError(HttpStatusCode status) { // Arrange var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Put, httpStatusCode: status); var invoiceClient = new ServiceInvoiceClient(TestHelper.apiKey, mockHttp); // Act var result = await invoiceClient.SendEmailAsync(TestHelper.companyId, TestHelper.invoiceId, CancellationToken.None); // Assert Assert.NotNull(result); Assert.Equal(ResultStatusCode.Error, result.Status); }
public async Task SendEmailAsync_WhenRequestResponseReturnNull_ReturnsError() { // Arrange var mockHttp = TestHelper.CreateMockHttpGet(null); var invoiceClient = new ServiceInvoiceClient(TestHelper.apiKey, mockHttp.Object); // Act var result = await invoiceClient.SendEmailAsync(TestHelper.companyId, TestHelper.invoiceId, CancellationToken.None); // Assert Assert.NotNull(result); Assert.Equal(ResultStatusCode.Error, result.Status); Assert.Equal("Object reference not set to an instance of an object.", result.Value.ToString()); }
public async Task SendEmailAsync_WhenSendValidJson_ReturnsOk() { // Arrange var resultPost = await _client.PostAsync(_companyIdSP, _item); // waiting nfe.io's server change invoice's NotaFiscalFlowStatus property to ISSUED Thread.Sleep(TimeSpan.FromSeconds(5)); resultPost.ValueAsSuccess.FlowStatus = NotaFiscalFlowStatus.Issued; // Act var result = await _client.SendEmailAsync(_companyIdSP, resultPost.ValueAsSuccess.Id); // Assert Assert.NotNull(result); Assert.Equal(ResultStatusCode.OK, result.Status); }