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); }
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); }
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); }