public void RandomJoke_ReturnsNull_WhenJokeIsNull() { var factory = new Mock <IBusinessFactory>(); factory.Setup(src => src.GetBusinessClass <IJokeBusiness>().GetRandomJoke()).Returns(new JokeModel()); var controller = new JokesController(factory.Object); var returns = controller.RandomJoke() as NegotiatedContentResult <JokeModel>; Assert.IsNull(returns); }
public void RandomJoke_ReturnsJokeModel_WhenJokeIsNotNull() { var randomJoke = new JokeModel { Joke = "this is not a joke" }; var factory = new Mock <IBusinessFactory>(); factory.Setup(src => src.GetBusinessClass <IJokeBusiness>().GetRandomJoke()).Returns(randomJoke); var controller = new JokesController(factory.Object); var returns = controller.RandomJoke() as OkNegotiatedContentResult <JokeModel>; Assert.AreEqual(returns.Content, randomJoke); }