Exemple #1
0
        public IViewComponentResult Invoke(CountryArgsModel args)
        {
            var dbItems   = UnitOfWork.Countries.GetCountries(args.Search, args.PagingSortingInfo);
            var countries = Mapper.Map <List <CountryListItemModel> >(dbItems);

            return(View(new CountryListModel(args, countries)));
        }
Exemple #2
0
        public void Invoke_Success()
        {
            var compMock = ViewComponentTestFactory.CreateMock(new CountryListViewComponent());

            compMock.MockRepository(r => r.Countries);

            var countryListItemModels = new List <CountryListItemModel>();
            var args = new CountryArgsModel {
                Search = "MySearch"
            };

            compMock.Mapper.Setup(x => x.Map <List <CountryListItemModel> >(It.IsAny <List <Country> >()))
            .Returns((List <Country> source) => countryListItemModels);

            var res   = (ViewViewComponentResult)compMock.Comp.Invoke(args);
            var model = (CountryListModel)res.ViewData.Model;

            Assert.AreEqual(countryListItemModels, model.Items);
            Assert.AreEqual(args.Search, model.Args.Search);
        }
Exemple #3
0
 public IActionResult GetCountriesList(CountryArgsModel args)
 {
     return(ViewComponent(typeof(CountryListViewComponent), new { args }));
 }