public void JokesByTerm_ReturnsNull_WhenNoJokesWereFound() { var jokeList = new List <JokeModel>(); var jokeModels = new JokesModels { Results = jokeList }; var factory = new Mock <IBusinessFactory>(); factory.Setup(src => src.GetBusinessClass <IJokeBusiness>().GetJokesByTerm(It.IsAny <string>())).Returns(jokeModels); var controller = new JokesController(factory.Object); var returns = controller.JokesByTerm("this") as NegotiatedContentResult <JokesModels>; Assert.IsNull(returns); }
public void JokesByTerm_ReturnsJokeModels_WhenItHasJokes() { var jokeModel = new JokeModel { Joke = "this is not a joke" }; var jokeList = new List <JokeModel> { jokeModel }; var jokeModels = new JokesModels { Results = jokeList }; var factory = new Mock <IBusinessFactory>(); factory.Setup(src => src.GetBusinessClass <IJokeBusiness>().GetJokesByTerm(It.IsAny <string>())).Returns(jokeModels); var controller = new JokesController(factory.Object); var returns = controller.JokesByTerm("this") as OkNegotiatedContentResult <JokesModels>; Assert.AreEqual(returns.Content, jokeModels); }