public void ReturnInstance_WhenParametersAreNotNull()
        {
            //Arrange
            var brands                = new Mock <IBrandsService>();
            var topics                = new Mock <ITopicsService>();
            var categories            = new Mock <ICategoriesService>();
            var cache                 = new Mock <ICacheService>();
            var dropDownListPopulator = new DropDownListPopulator(categories.Object, brands.Object, topics.Object, cache.Object);

            //Act & Assert
            Assert.IsInstanceOf <IDropDownListPopulator>(dropDownListPopulator);
        }
Example #2
0
        public void ReturnCorrectModelInstance()
        {
            //Arrange
            var brands               = new Mock <IBrandsService>();
            var topics               = new Mock <ITopicsService>();
            var categories           = new Mock <ICategoriesService>();
            var cache                = new Mock <ICacheService>();
            var categoriesCollection = DataHelper.GetSessionCategories();

            cache.Setup(x => x.Get(It.IsAny <string>(), It.IsAny <Func <IEnumerable <SelectListItem> > >())).Returns(categoriesCollection);
            var dropDownListPopulator = new DropDownListPopulator(categories.Object, brands.Object, topics.Object, cache.Object);

            //Act
            var result = dropDownListPopulator.GetCategories();

            //Assert
            Assert.IsInstanceOf <IEnumerable <SelectListItem> >(result);
        }
Example #3
0
        public void ReturnsCorrectModel()
        {
            //Arrange
            var brands               = new Mock <IBrandsService>();
            var topics               = new Mock <ITopicsService>();
            var categories           = new Mock <ICategoriesService>();
            var cache                = new Mock <ICacheService>();
            var categoriesCollection = DataHelper.GetSessionCategories();

            cache.Setup(x => x.Get(It.IsAny <string>(), It.IsAny <Func <IEnumerable <SelectListItem> > >())).Returns(categoriesCollection);
            var dropDownListPopulator = new DropDownListPopulator(categories.Object, brands.Object, topics.Object, cache.Object);

            //Act
            var result = dropDownListPopulator.GetCategories();

            //Assert
            Assert.IsNotNull(result);
            Assert.AreEqual(categoriesCollection, result);
            Assert.AreEqual(categoriesCollection.FirstOrDefault().Value, result.FirstOrDefault().Value);
            Assert.AreEqual(categoriesCollection.FirstOrDefault().Text, result.FirstOrDefault().Text);
        }