public async Task <ActionResult> GetRandomJoke() { var handler = new DadJokeHandler(new DadJokeService()); var vm = await handler.GetRandomJoke(); return(Json(new { Result = vm.Joke }, JsonRequestBehavior.AllowGet)); }
public async Task VerifyGetRandomJokeHydratesModel() { // Arrange _jokeService.Setup(s => s.GetRandomJoke()).Returns(Task.FromResult(new DadJoke { Id = "1235", Joke = "Knock knock...whos there..." }) ); var handler = new DadJokeHandler(_jokeService.Object); // Act var vm = await handler.GetRandomJoke(); // Assert Assert.IsTrue(!string.IsNullOrWhiteSpace(vm.Joke)); }