public async Task DemandBook_ValidInput_Add_Success() { // Arrange var exisitngCount = UserDemandServiceGenerator.GetUserDemandDataCollection().Count; var bookId = SearchBookServiceGenerator.GetDataCollection()[0].Id; var userName = UserManagerGenerator.GetDataCollection()[2].UserName; var requestModel = new DemandBookRequestModel { BookId = bookId.ToString(), UserName = userName }; // Act var response = controller.Post(requestModel); dynamic responseContent = await response.Content.ReadAsAsync <ExpandoObject>(); // Assert Assert.IsTrue(response.StatusCode == System.Net.HttpStatusCode.OK); Assert.IsTrue(exisitngCount + 1 == UserDemandServiceGenerator.GetUserDemandDataCollection().Count); }
public HttpResponseMessage Post([FromBody] DemandBookRequestModel requestModel) { var response = userDemandService.DemandBook(requestModel.BookId, requestModel.UserName); return(Request.CreateResponse(HttpStatusCode.OK, new { response.IsSucceed, message = response.Message })); }