public async Task DeleteAsync_WhenRequestTimeout_ReturnsTimeout() { // Arrange var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Post, httpStatusCode: HttpStatusCode.RequestTimeout); var companyClient = new CompanyClient(TestHelper.apiKey, mockHttp); // Act var result = await companyClient.DeleteAsync(TestHelper.apiKey, CancellationToken.None); // Assert Assert.NotNull(result); Assert.Equal(ResultStatusCode.TimedOut, result.Status); }
public async Task DeleteAsync_WhenSendInvalidApiKey_ReturnsUnauthorized() { // Arrange var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Post, httpStatusCode: HttpStatusCode.Unauthorized); var companyClient = new CompanyClient("InvalidApiKey", mockHttp); // Act var result = await companyClient.DeleteAsync(TestHelper.apiKey, CancellationToken.None); // Assert Assert.NotNull(result); Assert.Equal(ResultStatusCode.Unauthorized, result.Status); }
public async Task DeleteAsync_WhenRequestResponseReturnNull_ReturnsError() { // Arrange var mockHttp = TestHelper.CreateMockHttpGet("testToException"); var companyClient = new CompanyClient(TestHelper.apiKey, mockHttp.Object); // Act var result = await companyClient.DeleteAsync(TestHelper.apiKey, CancellationToken.None); // Assert Assert.NotNull(result); Assert.Equal(ResultStatusCode.Error, result.Status); }
public async Task DeleteAsync_WhenSendValidJson_ReturnsOk() { // Arrange var mockHttp = TestHelper.CreateMockHttp(HttpMethod.Get, _companyReturn); var companyClient = new CompanyClient(TestHelper.apiKey, mockHttp); // Act var result = await companyClient.DeleteAsync(TestHelper.companyId, CancellationToken.None); // Assert Assert.NotNull(result); Assert.Equal(ResultStatusCode.OK, result.Status); }
public async Task DeleteAsync_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.DeleteAsync(TestHelper.apiKey, CancellationToken.None); // Assert Assert.NotNull(result); Assert.Equal(ResultStatusCode.Error, result.Status); }
public async Task DeleteAsync_WhenSendValidCompanyJson_ReturnsDeleted() { // Arrange var company = await _client.PostAsync(_company); // Act var result = await _client.DeleteAsync(company.ValueAsSuccess.Id); company = await _client.PostAsync(_company); // Assert Assert.NotNull(result); Assert.Equal(ResultStatusCode.OK, result.Status); }