示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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());
        }
示例#5
0
        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);
        }