Exemplo n.º 1
0
        public void Should_return_many_teams_When_filter_by_nonempty_similar_name(string name)
        {
            //arrange
            var filterVm = new TeamFilterVm { SearchString = name };

            //act
            var teams = _teamService.RetreiveList(filterVm).Teams;

            //assert
            teams.ShouldAllBeEquivalentTo(_teams);
        }
Exemplo n.º 2
0
        public void Should_Return_All_Teams_When_Filter_By_Empty_String(string searchString)
        {
            //arrange
            var filterVm = new TeamFilterVm { SearchString = searchString };

            //act
            var teams = _teamService.RetreiveList(filterVm).Teams;

            //assert
            teams.ShouldAllBeEquivalentTo(_teams);
        }
Exemplo n.º 3
0
        public TeamsVm RetreiveList(TeamFilterVm filterVm)
        {
            updatePagingData(filterVm);
            var filter = filterVm.Map();
            var teams = _unit.Team.Load(filter);

            return new TeamsVm
            {
                Teams = teams,
                Filter = filterVm
            };
        }
Exemplo n.º 4
0
        public void Can_Paginate_Sort_And_Search_Teams(string searchString, string sortByField, int pageSize, int lookupPage, string[] expectedNames)
        {
            //arrange
            _config.PageSize = pageSize;
            var filterVm = new TeamFilterVm
                               {
                                   SearchString = searchString,
                                   SortByField = sortByField,
                                   Page = lookupPage
                               };

            //act
            var teams = _teamService.RetreiveList(filterVm).Teams;

            //assert
            teams.Select(team => team.Name).ShouldAllBeEquivalentTo(expectedNames);
        }
Exemplo n.º 5
0
        private void updatePagingData(TeamFilterVm filter)
        {
            var teams = _unit.Team.Load()
                             .WhereIf(filter.SearchString.IsNotEmpty(), x => x.Name.Contains(filter.SearchString))
                             .Where(x => x.Live == LiveStatuses.Active);

            filter.TotalPages = PageCounter.GetTotalPages(teams.Count(), Config.Instance.PageSize);
            filter.Page = PageCounter.GetRangedPage(filter.Page, filter.TotalPages);
        }
Exemplo n.º 6
0
        public void Should_return_no_team_When_filter_by_nonexistent_not_empty_name(string searchString)
        {
            //arrange
            var filterVm = new TeamFilterVm { SearchString = searchString };

            //act
            var teams = _teamService.RetreiveList(filterVm).Teams;

            //assert
            teams.Should().BeEmpty();
        }
Exemplo n.º 7
0
        public void Should_return_team_When_filter_by_name_of_existing_team()
        {
            //arrange
            var testedTeam = _teams[0];
            var filterVm = new TeamFilterVm { SearchString = testedTeam.Name };

            var expectedList = new[] { testedTeam };

            //act
            var teams = _teamService.RetreiveList(filterVm).Teams;

            //assert
            teams.ShouldAllBeEquivalentTo(expectedList);
        }
Exemplo n.º 8
0
 public ActionResult List(TeamFilterVm filter)
 {
     return PartialView(_service.RetreiveList(filter));
 }