public async void Http_trigger_interal_server_error() { //intentionally not set the enviroment: this simulates problem with the DB //TestUtil.SetConfiguration(); string urlfull = "www.microsoft.com"; var request = TestFactory.CreateHttpRequest("UrlFull", urlfull); var response = (StatusCodeResult)await FunctionShorten.Run(request, logger); Assert.Equal(500, response.StatusCode); }
public async void Http_trigger_no_input() { var request = TestFactory.CreateHttpRequest("", ""); var response = (ObjectResult)await FunctionShorten.Run(request, logger); var expect = new BadRequestObjectResult("No input full URL"); Assert.Equal(expect.Value, response.Value); Assert.Equal(expect.StatusCode, response.StatusCode); }
//common code private async System.Threading.Tasks.Task <string> GetShortUrlAsync(string urlfull) { TestUtil.SetConfiguration(); var request = TestFactory.CreateHttpRequest("UrlFull", urlfull); var response = (ObjectResult)await FunctionShorten.Run(request, logger); var expect = new OkObjectResult(""); Assert.Equal(expect.StatusCode, response.StatusCode); string shorturl = response.Value.ToString(); return(shorturl); }