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); }
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); }
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); }
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); }
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); }
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); }