/// <inheritdoc/> public Array GetImageArrayVariant() { IRestRequest request = BuildGetImageArrayVariantRequest(); IRestResponse response = CommandSender.ExecuteRequest(Configuration.GetBaseUrl(), request); return(ParseImageResponse(response)); }
public void GivenRequestCompletedOnError_ExecuteRequest_ThrowsAlpacaException() { //Arrange IRestResponse restResponse = new RestResponse(); restResponse.Content = ""; restResponse.ResponseStatus = ResponseStatus.Completed; restResponse.StatusCode = HttpStatusCode.BadRequest; CommandSender commandSender = InitCommandSender(restResponse.Content, restResponse); //Act/Assert Assert.Throws <AlpacaException>(() => commandSender.ExecuteRequest <CommandResponse>("", new RestRequest())); }
public void GivenTimeoutRequest_ExecuteRequest_ThrowsAlpacaException() { //Arrange IRestResponse restResponse = new RestResponse(); restResponse.Content = ""; restResponse.ResponseStatus = ResponseStatus.TimedOut; restResponse.StatusCode = 0; CommandSender commandSender = InitCommandSender(restResponse.Content, restResponse); //Act/Assert Assert.Throws <AlpacaException>(() => commandSender.ExecuteRequest <CommandResponse>("", new RestRequest())); }
public void GivenValidRequest_ExecuteRequest_Returns_ExpectedCommandResponse(string jsonResponse, CommandResponse expectedDeserializedResponse) { //Arrange IRestResponse restResponse = new RestResponse(); restResponse.Content = jsonResponse; restResponse.ResponseStatus = ResponseStatus.Completed; restResponse.StatusCode = HttpStatusCode.OK; CommandSender commandSender = InitCommandSender(jsonResponse, restResponse); //Act var response = commandSender.ExecuteRequest <CommandResponse>("", new RestRequest()); //Assert Assert.Equal(expectedDeserializedResponse.ErrorMessage, response.ErrorMessage); Assert.Equal(expectedDeserializedResponse.ErrorNumber, response.ErrorNumber); Assert.Equal(expectedDeserializedResponse.ClientTransactionID, response.ClientTransactionID); Assert.Equal(expectedDeserializedResponse.ServerTransactionID, response.ServerTransactionID); }