public ActionResult <BoardAddOutput> Add(BoardAddInput input) { CreateBoardCommand command = _mapper.Map <BoardAddInput, CreateBoardCommand>(input); command.BoardId = Guid.NewGuid().ToString(); Task <CreateBoardCommandResult> result = _boardService.Add(command); BoardAddOutput returnValue = _mapper.Map <CreateBoardCommandResultItem, BoardAddOutput>(result.Result.ResultObject.Data); foreach (var item in result.Result.ResultObject.GetErrorMessageList()) { returnValue.MessageList.Add(item.UserFriendlyText); } if (result.Result.ResultObject.Success) { returnValue.IsSuccess = true; return(Ok(returnValue)); } else { returnValue.IsSuccess = false; return(BadRequest(returnValue)); } }
public void Add_StateUnderTest_ExpectedBehavior() { // Arrange var boardController = this.CreateBoardController(); BoardAddInput input = null; // Act var result = boardController.Add( input); // Assert Assert.True(false); this.mockRepository.VerifyAll(); }
public async Task Post_WithoutName_ReturnsBadRequest() { BoardAddInput boardAddInputModel = new BoardAddInput { BoardId = "247234", Name = "BoardTest", Description = "Açýklama", OwnerId = "MYUCADAG" }; var response = await _client.PostAsJsonAsync("Board/Add", boardAddInputModel, JsonSerializerHelper.DefaultSerialisationOptions); string Content = await response.Content.ReadAsStringAsync(); //dynamic json = JsonConvert.DeserializeObject(Content); //.ReadFromJsonAsync<ActionResult<ServiceResult<CreateBoardCommandResult>>>(); // var problemDetails = await response.Content.ReadFromJsonAsync<ActionResult<ServiceResult<CreateBoardCommandResult>>>(); //.ReadAsStringAsync(); //<ActionResult<ServiceResult<CreateBoardCommandResult>>>(); //JObject googleSearch = JObject.Parse(Content); //JToken Result = googleSearch["result"]["resultObject"]["data"]; //CreateBoardCommandResultItem ReulstObject = Result.ToObject<CreateBoardCommandResultItem>(); // get JSON result objects into a list // IList<JToken> results = googleSearch["result"]["resultObject"].Children().ToList(); // serialize JSON results into .NET objects //IList<SearchResult> searchResults = new List<SearchResult>(); //foreach (JToken result in results) //{ // // JToken.ToObject is a helper method that uses JsonSerializer internally // SearchResult searchResult = result.ToObject<SearchResult>(); // searchResults.Add(searchResult); //} response.StatusCode.ShouldBe(HttpStatusCode.OK); }