public void retrievefornotificationsError() { //Arrange RetrieveNotification notification = new RetrieveNotification() { Teacher = "", Notification = "" }; // Act var badResponse = _controller.retrievefornotifications(notification); // Assert Assert.IsType <BadRequestObjectResult>(badResponse); }
public void retrievefornotifications() { //Arrange RetrieveNotification notification = new RetrieveNotification() { Teacher = "*****@*****.**", Notification = "Hello students!" }; // Act var okResult = _controller.retrievefornotifications(notification); // Assert Assert.IsType <OkObjectResult>(okResult); }
public IActionResult retrievefornotifications(RetrieveNotification retrieveNotification) { try { if (String.IsNullOrEmpty(retrieveNotification.Teacher) || String.IsNullOrEmpty(retrieveNotification.Notification)) { processingError = badrequest; throw new ProcessingException(); } //Extract teacher and notification from request body string teacher = retrieveNotification.Teacher.ToString(); string notification = retrieveNotification.Notification.ToString(); var recipients = _ihiringRepositorty.retrievefornotifications(teacher, notification); if (recipients == null) { processingError = notfound; throw new ProcessingException(); } return(Ok(JsonConvert.SerializeObject(recipients, Formatting.Indented))); } catch (ProcessingException) { // TO-DO: Handle processing exception error error = new error { message = processingError.ToString() }; return(BadRequest(error)); } catch (Exception) { // TO-DO: Handle the non processing related exception return(BadRequest()); } }