Esempio n. 1
0
        public async Task DeleteAsync_WhenRequestTimeout_ReturnsTimeout()
        {
            // Arrange
            var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Delete, httpStatusCode: HttpStatusCode.RequestTimeout);

            var invoiceClient = new ServiceInvoiceClient(TestHelper.apiKey, mockHttp);

            // Act
            var result = await invoiceClient.DeleteAsync(TestHelper.companyId, TestHelper.invoiceId, CancellationToken.None);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(ResultStatusCode.TimedOut, result.Status);
        }
Esempio n. 2
0
        public async Task DeleteAsync_WhenSendInvalidApiKey_ReturnsUnauthorized()
        {
            // Arrange
            var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Delete, httpStatusCode: HttpStatusCode.Unauthorized);

            var invoiceClient = new ServiceInvoiceClient("InvalidApiKey", mockHttp);

            // Act
            var result = await invoiceClient.DeleteAsync(TestHelper.companyId, TestHelper.invoiceId, CancellationToken.None);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(ResultStatusCode.Unauthorized, result.Status);
        }
Esempio n. 3
0
        public async Task DeleteAsync_WhenHttpStatusCodeIsUnexpected_ReturnsError(HttpStatusCode status)
        {
            // Arrange
            var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Delete, httpStatusCode: status);

            var invoiceClient = new ServiceInvoiceClient(TestHelper.apiKey, mockHttp);

            // Act
            var result = await invoiceClient.DeleteAsync(TestHelper.companyId, TestHelper.invoiceId, CancellationToken.None);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(ResultStatusCode.Error, result.Status);
        }
Esempio n. 4
0
        public async Task DeleteAsync_WhenRequestResponseReturnNull_ReturnsError()
        {
            // Arrange
            var mockHttp = TestHelper.CreateMockHttpGet(null);

            var invoiceClient = new ServiceInvoiceClient(TestHelper.apiKey, mockHttp.Object);

            // Act
            var result = await invoiceClient.DeleteAsync(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());
        }
Esempio n. 5
0
        public async Task DeleteAsync_WhenInvoiceIdIsValid_ReturnsOk()
        {
            // Arrange
            var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Delete, string.Empty);

            var invoiceClient = new ServiceInvoiceClient(TestHelper.apiKey, mockHttp);

            // Act
            var result = await invoiceClient.DeleteAsync(TestHelper.companyId, TestHelper.invoiceId, CancellationToken.None);

            // Assert
            Assert.NotNull(result);
            Assert.Null(result.ValueAsSuccess);
            Assert.Equal(ResultStatusCode.OK, result.Status);
        }
Esempio n. 6
0
        public async Task DeleteAsync_WhenSendInvoiceIdValid_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.DeleteAsync(_companyIdSP, resultPost.ValueAsSuccess.Id);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(ResultStatusCode.OK, result.Status);
        }