コード例 #1
0
        public async Task GetOneAsync_WhenCompanyIdIsValid_ReturnsOk()
        {
            // Arrange

            // Act
            var result = await _client.GetOneAsync(_companyIdSP);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(ResultStatusCode.OK, result.Status);
            ValidateHelper.ValidateCompany(_companyReturn.JsonToObject <LegalPerson>(), result.ValueAsSuccess);
        }
コード例 #2
0
        public async Task GetOneAsync_WhenRequestTimeout_ReturnsTimeout()
        {
            // Arrange
            var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Post, httpStatusCode: HttpStatusCode.RequestTimeout);

            var companyClient = new CompanyClient(TestHelper.apiKey, mockHttp);

            // Act
            var result = await companyClient.GetOneAsync(TestHelper.apiKey, CancellationToken.None);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(ResultStatusCode.TimedOut, result.Status);
        }
コード例 #3
0
        public async Task GetOneAsync_WhenSendInvalidApiKey_ReturnsUnauthorized()
        {
            // Arrange
            var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Post, httpStatusCode: HttpStatusCode.Unauthorized);

            var companyClient = new CompanyClient("InvalidApiKey", mockHttp);

            // Act
            var result = await companyClient.GetOneAsync(TestHelper.apiKey, CancellationToken.None);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(ResultStatusCode.Unauthorized, result.Status);
        }
コード例 #4
0
        public async Task GetOneAsync_WhenRequestResponseReturnNull_ReturnsError()
        {
            // Arrange
            var mockHttp = TestHelper.CreateMockHttpGet("testToException");

            var companyClient = new CompanyClient(TestHelper.apiKey, mockHttp.Object);

            // Act
            var result = await companyClient.GetOneAsync(TestHelper.apiKey, CancellationToken.None);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(ResultStatusCode.Error, result.Status);
        }
コード例 #5
0
        public async Task GetOneAsync_WhenHttpStatusCodeIsUnexpected_ReturnsError(HttpStatusCode status)
        {
            // Arrange
            var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Post, httpStatusCode: status);

            var companyClient = new CompanyClient(TestHelper.apiKey, mockHttp);

            // Act
            var result = await companyClient.GetOneAsync(TestHelper.apiKey, CancellationToken.None);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(ResultStatusCode.Error, result.Status);
        }
コード例 #6
0
        public async Task GetOneAsync_WhenSendValidJson_ReturnsOk()
        {
            // Arrange
            var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Get, _companyReturn);

            var companyClient = new CompanyClient(TestHelper.apiKey, mockHttp);

            // Act
            var result = await companyClient.GetOneAsync(TestHelper.companyId, CancellationToken.None);

            // Assert
            Assert.NotNull(result);
            Assert.Equal(ResultStatusCode.OK, result.Status);
            ValidateHelper.ValidateCompany(_company, result.ValueAsSuccess);
        }