예제 #1
0
        public async Task GetDocumentXmlAsync_WhenSendInvoiceIdValid_ReturnsOk()
        {
            // Arrange

            // Act
            var result = await _client.GetDocumentXmlAsync(_companyIdSP, _invoiceId);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(ResultStatusCode.OK, result.Status);
        }
예제 #2
0
        public async Task GetDocumentXmlAsync_WhenRequestTimeout_ReturnsTimeout()
        {
            // Arrange
            var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Get, "testToException", httpStatusCode: HttpStatusCode.RequestTimeout);

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

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

            // Assert
            Assert.NotNull(result);
            Assert.Equal(ResultStatusCode.TimedOut, result.Status);
        }
예제 #3
0
        public async Task GetDocumentXmlAsync_WhenSendInvalidApiKey_ReturnsUnauthorized()
        {
            // Arrange
            var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Get, "testToException", httpStatusCode: HttpStatusCode.Unauthorized);

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

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

            // Assert
            Assert.NotNull(result);
            Assert.Equal(ResultStatusCode.Unauthorized, result.Status);
        }
예제 #4
0
        public async Task GetDocumentXmlAsync_WhenRequestResponseReturnNull_ReturnsError()
        {
            // Arrange
            var mockHttp = TestHelper.CreateMockHttpGet(null);

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

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

            // Assert
            Assert.NotNull(result);
            Assert.Equal(ResultStatusCode.Error, result.Status);
            Assert.Equal("String reference not set to an instance of a String.\r\nParameter name: s", result.Value.ToString());
        }
예제 #5
0
        public async Task GetDocumentXmlAsync_WhenInvoiceIdIsValid_ReturnsOk()
        {
            // Arrange
            var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Get, _xmlToTest);

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

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

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