示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        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);
        }