public async Task GetAllCowsAsync() { await DataBaseHelper.ClearDatabaseAsync(); var newFirstCow = new CreateCowCommand { FarmId = Guid.NewGuid(), State = CowState.Open }; var newSecondCow = new CreateCowCommand { FarmId = Guid.NewGuid(), State = CowState.Pregnant }; var firstCow = CowsApi.ApiV1CowsPost(newFirstCow); var secondCow = CowsApi.ApiV1CowsPost(newSecondCow); var result = CowsApi.ApiV1CowsGet(); Assert.Equal(2, result.Count); Assert.Equal(firstCow.Id, result[0].Id); Assert.Equal(firstCow.FarmId, result[0].FarmId); Assert.Equal(firstCow.State, result[0].State); Assert.Equal(secondCow.Id, result[1].Id); Assert.Equal(secondCow.FarmId, result[1].FarmId); Assert.Equal(secondCow.State, result[1].State); }
/// <summary> /// /// </summary> /// <param name="body"></param> /// <returns>Cow</returns> public Cow ApiV1CowsPost(CreateCowCommand body) { var path = "/api/v1/cows"; path = path.Replace("{format}", "json"); var queryParams = new Dictionary <String, String>(); var headerParams = new Dictionary <String, String>(); var formParams = new Dictionary <String, String>(); var fileParams = new Dictionary <String, FileParameter>(); String postBody = null; postBody = ApiClient.Serialize(body); // http body (model) parameter // authentication setting, if any String[] authSettings = new String[] { }; // make the HTTP request IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { throw new ApiException((int)response.StatusCode, "Error calling ApiV1CowsPost: " + response.Content, response.Content); } else if (((int)response.StatusCode) == 0) { throw new ApiException((int)response.StatusCode, "Error calling ApiV1CowsPost: " + response.ErrorMessage, response.ErrorMessage); } return((Cow)ApiClient.Deserialize(response.Content, typeof(Cow), response.Headers)); }
public Task Put(Guid id, [FromBody] CreateCowCommand request) { var update = new UpdateCowCommand { Id = id, FarmId = request.FarmId, State = request.State }; return(_mediator.Send(update)); }
public void CreateCow() { var newCow = new CreateCowCommand { FarmId = Guid.NewGuid(), State = CowState.Open }; var cow = CowsApi.ApiV1CowsPost(newCow); Assert.Equal(newCow.FarmId, cow.FarmId); Assert.Equal(newCow.State, cow.State); Assert.NotEqual(Guid.Empty, cow.Id); }
public void GetCow() { var newCow = new CreateCowCommand { FarmId = Guid.NewGuid(), State = CowState.Pregnant }; var cow = CowsApi.ApiV1CowsPost(newCow); var result = CowsApi.ApiV1CowsIdGet(cow.Id); Assert.Equal(newCow.FarmId, cow.FarmId); Assert.Equal(newCow.State, cow.State); Assert.Equal(cow.FarmId, result.FarmId); Assert.Equal(cow.State, result.State); Assert.Equal(cow.Id, result.Id); }
public void DeleteCow() { var newCow = new CreateCowCommand { FarmId = Guid.NewGuid(), State = CowState.Inseminated }; var cow = CowsApi.ApiV1CowsPost(newCow); var result = CowsApi.ApiV1CowsIdGet(cow.Id); Assert.Equal(newCow.FarmId, cow.FarmId); Assert.Equal(newCow.State, cow.State); Assert.Equal(cow.FarmId, result.FarmId); Assert.Equal(cow.State, result.State); Assert.Equal(cow.Id, result.Id); CowsApi.ApiV1CowsIdDelete(cow.Id); result = CowsApi.ApiV1CowsIdGet(cow.Id); Assert.Null(result); }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="body"></param> /// <returns></returns> public void ApiV1CowsIdPut(Guid?id, CreateCowCommand body) { // verify the required parameter 'id' is set if (id == null) { throw new ApiException(400, "Missing required parameter 'id' when calling ApiV1CowsIdPut"); } var path = "/api/v1/cows/{id}"; path = path.Replace("{format}", "json"); path = path.Replace("{" + "id" + "}", ApiClient.ParameterToString(id)); var queryParams = new Dictionary <String, String>(); var headerParams = new Dictionary <String, String>(); var formParams = new Dictionary <String, String>(); var fileParams = new Dictionary <String, FileParameter>(); String postBody = null; postBody = ApiClient.Serialize(body); // http body (model) parameter // authentication setting, if any String[] authSettings = new String[] { }; // make the HTTP request IRestResponse response = (IRestResponse)ApiClient.CallApi(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings); if (((int)response.StatusCode) >= 400) { throw new ApiException((int)response.StatusCode, "Error calling ApiV1CowsIdPut: " + response.Content, response.Content); } else if (((int)response.StatusCode) == 0) { throw new ApiException((int)response.StatusCode, "Error calling ApiV1CowsIdPut: " + response.ErrorMessage, response.ErrorMessage); } return; }
public Task <Cow> Post([FromBody] CreateCowCommand request) { return(_mediator.Send(request)); }