public IActionResult Greet( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req) { log.LogInformation("C# HTTP trigger function processed a request."); string name = req.Query["name"]; return(name != null ? (ActionResult) new OkObjectResult(greetService.Greet(name)) : new BadRequestObjectResult("Please pass a name on the query string or in the request body")); }
public void should_greet_with_name_given() { var httpRequest = TestFactory.CreateHttpRequest("name", TestName); A.CallTo(() => greetService.Greet(TestName)).Returns("Welcome!"); var greetFunctions = new GreetFunctions(greetService, log); var response = (OkObjectResult)greetFunctions.Greet(httpRequest); Assert.That(log.Logs[0], Is.EqualTo("C# HTTP trigger function processed a request.")); Assert.That(response.Value, Is.EqualTo("Welcome!")); }
public void Greet(string name) { Console.WriteLine(_greetService.Greet(name)); }