public async Task given_past_target_date_exception_should_be_thrown() { var token = await Login("*****@*****.**", "secretpassword"); var request = new AddUserPlan { plannedWeight = 40, targetDate = DateTime.Parse("02/02/2010") }; var payload = GetPayload(request); Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); var response = await Client.PostAsync("users/me/plan", payload); var responseMessage = await ConvertResponseToExceptionDTOAsync(response); Assert.AreEqual(responseMessage.StatusCode, HttpStatusCode.InternalServerError); Assert.AreEqual(responseMessage.Message, "Please provide future date"); }
public async Task given_negative_weight_exception_should_be_thrown() { var token = await Login("*****@*****.**", "secretpassword"); var request = new AddUserPlan { plannedWeight = -40, targetDate = DateTime.Parse("02/02/2020") }; var payload = GetPayload(request); Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); var response = await Client.PostAsync("users/me/plan", payload); var responseMessage = await ConvertResponseToExceptionDTOAsync(response); //TODO: CustomException: InproperDataException Assert.AreEqual(responseMessage.StatusCode, HttpStatusCode.InternalServerError); Assert.AreEqual(responseMessage.Message, "You cannot plan to have negative weight"); }
public async Task <IActionResult> PostPlan([FromBody] AddUserPlan command) { await DispatchAsync(command); return(Created($"users/me/plan", new object())); }