public void EnsureSuccess_Successfull_NoException()
        {
            // Arrange
            const string reason       = "Test";
            var          factory      = Substitute.For <IHttpResponseFactory>();
            var          httpResponse = CreateResponse(HttpStatusCode.Accepted, reason, null);
            var          apiResponse  = new ApiCommandResponse(factory, httpResponse);

            // Act
            apiResponse.EnsureSuccess();

            // Arrange
            Assert.True(apiResponse.IsSuccess);
            Assert.Equal(HttpStatusCode.Accepted, apiResponse.StatusCode);
            Assert.Equal(reason, apiResponse.Reason);
        }
        public void EnsureSuccess_NotSuccessfull_ThrowsException()
        {
            // Arrange
            const string reason       = "Test";
            var          factory      = Substitute.For <IHttpResponseFactory>();
            var          httpResponse = CreateResponse(HttpStatusCode.BadGateway, reason, null);
            var          apiResponse  = new ApiCommandResponse(factory, httpResponse);

            // Act
            var exception = Assert.Throws <ApiCommandException>(() => apiResponse.EnsureSuccess());

            // Assert
            Assert.Equal(HttpStatusCode.BadGateway, exception.StatusCode);
            Assert.Equal(reason, exception.Message);
            Assert.Same(apiResponse, exception.Response);

            Assert.False(apiResponse.IsSuccess);
            Assert.Equal(HttpStatusCode.BadGateway, apiResponse.StatusCode);
            Assert.Equal(reason, apiResponse.Reason);
        }