public void GetJokesByTerm_Returns_JokesModels_Type()
        {
            //Arrange
            var term = "red";
            var mockJokeRepository = new Mock <IJokeRepository>();

            mockJokeRepository.Setup(x => x.GetJokesByTerm(It.IsAny <string>())).Returns(new JokesModels());
            var mockRepositoryFactory = new Mock <IRepositoryFactory>();

            mockRepositoryFactory.Setup(x => x.GetDataRepository <IJokeRepository>()).Returns(mockJokeRepository.Object);
            var business = new JokeBusiness(mockRepositoryFactory.Object, new Shared.Utilities.JokesHelper());

            //Act
            JokesModels result = business.GetJokesByTerm(term);

            //Assert
            Assert.IsInstanceOfType(result, typeof(JokesModels));
        }
        public void GetJokesByTerm_ReturnsNull_WhenJokesModelsResults_AreNull()
        {
            //Arrange
            var term = "red";
            List <JokeModel> results = null;
            var mockJokeRepository   = new Mock <IJokeRepository>();

            mockJokeRepository.Setup(x => x.GetJokesByTerm(It.IsAny <string>())).Returns(new JokesModels()
            {
                Results = results, SearchTerm = "test"
            });
            var mockRepositoryFactory = new Mock <IRepositoryFactory>();

            mockRepositoryFactory.Setup(x => x.GetDataRepository <IJokeRepository>()).Returns(mockJokeRepository.Object);
            var mockHighlighter = new Mock <IHighlighter>();
            var business        = new JokeBusiness(mockRepositoryFactory.Object, new Shared.Utilities.JokesHelper());

            //Act
            JokesModels result = business.GetJokesByTerm(term);

            //Assert
            Assert.IsNull(result.Results);
        }
        public void GetJokesByTerm_ReturnsCorrectNumberOf_JokesModels()
        {
            //Arrange
            var term    = "red";
            var results = new List <JokeModel> {
                new JokeModel()
            };
            var mockJokeRepository = new Mock <IJokeRepository>();

            mockJokeRepository.Setup(x => x.GetJokesByTerm(It.IsAny <string>())).Returns(new JokesModels()
            {
                Results = results, SearchTerm = "test"
            });
            var mockRepositoryFactory = new Mock <IRepositoryFactory>();

            mockRepositoryFactory.Setup(x => x.GetDataRepository <IJokeRepository>()).Returns(mockJokeRepository.Object);
            var business = new JokeBusiness(mockRepositoryFactory.Object, new Shared.Utilities.JokesHelper());

            //Act
            JokesModels result = business.GetJokesByTerm(term);

            //Assert
            Assert.AreEqual(result.Results.Count, 1);
        }