public IEnumerable <string> Get() { LogNLog log = new LogNLog(); log.Debug("Get API called of Values Controller"); return(new string[] { "value1", "value2" }); }
public void Get_ReturnOkObjectResult_GetMentorDetails() { // Arrange ILog _log = new LogNLog(); var _userRepository = new UserRepository(DbContextMocker.GetUserContext()); var _userController = new UserController(_userRepository, _log); var testMentor = GetTestMentor(); // Act var response = _userController.GetMentorDetails("*****@*****.**"); // Assert var okObjectResult = Assert.IsType <OkObjectResult>(response); var data = Assert.IsAssignableFrom <UserService.Models.MentorDto>(okObjectResult.Value); Assert.Equal("*****@*****.**", data.MentorName); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ILogger log) { var message = new LogNLog(); message.Information("Dependency created.Logging started"); log.LogInformation("C# HTTP trigger function processed a request."); string name = req.Query["name"]; string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); dynamic data = JsonConvert.DeserializeObject(requestBody); name = name ?? data?.name; return(name != null ? (ActionResult) new OkObjectResult($"Hello, {name}") : new BadRequestObjectResult("Please pass a name on the query string or in the request body")); }