Ejemplo n.º 1
0
 public bool AddToSearch(SearchModel search)
 {
     return
         (search.Add(new CustomNodeInfo(FunctionId,
                                        WorkspaceModel.Name,
                                        WorkspaceModel.Category,
                                        WorkspaceModel.Description,
                                        WorkspaceModel.FileName)));
 }
Ejemplo n.º 2
0
        public void PopulateSearchTextWithSelectedResultReturnsExpectedResult()
        {
            var catName = "Animals";
            var descr   = "";
            var path    = "";

            model.Add(new CustomNodeInfo(Guid.NewGuid(), "xyz", catName, descr, path));
            model.Add(new CustomNodeInfo(Guid.NewGuid(), "abc", catName, descr, path));
            model.Add(new CustomNodeInfo(Guid.NewGuid(), "cat", catName, descr, path));
            model.Add(new CustomNodeInfo(Guid.NewGuid(), "dog", catName, descr, path));
            model.Add(new CustomNodeInfo(Guid.NewGuid(), "frog", catName, descr, path));
            model.Add(new CustomNodeInfo(Guid.NewGuid(), "Noodle", catName, descr, path));

            viewModel.SearchAndUpdateResults("xy");
            viewModel.PopulateSearchTextWithSelectedResult();
            Assert.AreEqual("xyz", viewModel.SearchText);

            viewModel.SearchAndUpdateResults("ood");
            viewModel.PopulateSearchTextWithSelectedResult();
            Assert.AreEqual("Noodle", viewModel.SearchText);

            viewModel.SearchAndUpdateResults("do");
            viewModel.PopulateSearchTextWithSelectedResult();
            Assert.AreEqual("dog", viewModel.SearchText);
        }
Ejemplo n.º 3
0
        public async override Task GetEntitiesFromServer()
        {
            List <Task> tasks = new List <Task>();

            Task <List <TeamModel> > entitiesTask = interactor.GetEntities("api/floorball/teams", "Error during getting teams");

            tasks.Add(entitiesTask);

            Task <List <LeagueModel> > leaguesTask = interactor.GetEntities <LeagueModel>("api/floorball/leagues", "Error during getting leagues");

            tasks.Add(leaguesTask);

            /*dTask<List<TeamModel>> teamsTask = interactor.GetEntities<TeamModel>("api/floorball/teams", "Error during getting teams");
             * tasks.Add(teamsTask);*/

            //Task<Dictionary<int, List<int>>> playersAndTeamsTask =  interactor.GetEntityMappings("api/floorball/players/teams", "Error during getting teams for player");

            await Task.WhenAll(tasks);

            var entities = entitiesTask.Result;
            var leagues  = leaguesTask.Result;
            //var teams = teamsTask.Result;

            TeamModel prevEntity = null;

            List <SearchCell> searchList = new List <SearchCell>();

            foreach (var entity in entities.OrderByDescending(e => e.LeagueId).ThenBy(e => e.Name))
            {
                if (prevEntity == null || entity.Name != prevEntity.Name)
                {
                    SearchModel.Add(new List <SearchCell>());
                    var league = leagues.Single(l => l.Id == entity.LeagueId);
                    Titles.Add(new SearchTitle {
                        MainTitle = league.Name, Subtitle = AppDelegate.SharedAppDelegate.TextManager.GetText(league.Gender)
                    });
                }

                SearchModel.Last().Add(new SearchCell
                {
                    Id          = entity.Id,
                    Title       = entity.Name,
                    Subtitle    = entity.Coach,
                    RightDetail = entity.Year.Year.ToString()
                });

                prevEntity = entity;
            }

            FilteredSearchModel = new List <List <SearchCell> >(SearchModel);
            FilteredTitles      = new List <SearchTitle>(Titles);
        }
        public async override Task GetEntitiesFromServer()
        {
            List <Task> tasks = new List <Task>();

            Task <List <StadiumModel> > entitiesTask = interactor.GetEntities("api/floorball/stadiums", "Error during getting stadiums");

            tasks.Add(entitiesTask);

            /*Task<List<LeagueModel>> leaguesTask = interactor.GetEntities<LeagueModel>("api/floorball/leagues", "Error during getting leagues");
             * tasks.Add(leaguesTask);
             *
             * Task<List<TeamModel>> teamsTask = interactor.GetEntities<TeamModel>("api/floorball/teams", "Error during getting teams");
             * tasks.Add(teamsTask);*/

            //Task<Dictionary<int, List<int>>> playersAndTeamsTask =  interactor.GetEntityMappings("api/floorball/players/teams", "Error during getting teams for player");

            await Task.WhenAll(tasks);

            var entities = entitiesTask.Result;

            /*var leagues = leaguesTask.Result;
             * var teams = teamsTask.Result;*/

            StadiumModel prevEntity = null;

            List <SearchCell> searchList = new List <SearchCell>();

            foreach (var entity in entities.OrderBy(e => e.Name))
            {
                if (prevEntity == null || entity.Name != prevEntity.Name)
                {
                    SearchModel.Add(new List <SearchCell>());
                    Titles.Add(new SearchTitle {
                        MainTitle = "", Subtitle = ""
                    });
                }

                SearchModel.Last().Add(new SearchCell
                {
                    Id          = entity.Id,
                    Title       = entity.Name,
                    Subtitle    = entity.Address,
                    RightDetail = ""
                });

                prevEntity = entity;
            }

            FilteredSearchModel = new List <List <SearchCell> >(SearchModel);
            FilteredTitles      = new List <SearchTitle>(Titles);
        }
        public async override Task GetEntitiesFromServer()
        {
            List <Task> tasks = new List <Task>();

            Task <List <MatchModel> > entitiesTask = interactor.GetEntities("api/floorball/matches", "Error during getting matches");

            tasks.Add(entitiesTask);

            Task <List <LeagueModel> > leaguesTask = interactor.GetEntities <LeagueModel>("api/floorball/leagues", "Error during getting leagues");

            tasks.Add(leaguesTask);

            Task <List <TeamModel> > teamsTask = interactor.GetEntities <TeamModel>("api/floorball/teams", "Error during getting teams");

            tasks.Add(teamsTask);

            await Task.WhenAll(tasks);

            var entities = entitiesTask.Result;
            var leagues  = leaguesTask.Result;
            var teams    = teamsTask.Result;

            MatchModel prevEntity = null;

            List <SearchCell> searchList = new List <SearchCell>();

            foreach (var entity in entities.OrderBy(e => e.LeagueId).ThenBy(e => e.Round).ThenBy(e => e.Date))
            {
                if (prevEntity == null || entity.LeagueId != prevEntity.LeagueId)
                {
                    SearchModel.Add(new List <SearchCell>());
                    var league = leagues.Single(l => l.Id == entity.LeagueId);
                    Titles.Add(new SearchTitle {
                        MainTitle = league.Name + " - " + TextManager.GetText(league.Class), Subtitle = TextManager.GetText(league.Gender)
                    });
                }

                SearchModel.Last().Add(new SearchCell
                {
                    Id          = entity.Id,
                    Title       = teams.Single(t => t.Id == entity.HomeTeamId).Name + " - " + teams.Single(t => t.Id == entity.AwayTeamId).Name,
                    Subtitle    = entity.Date.ToString("yyyy-MM-dd hh:mm"),
                    RightDetail = entity.Round.ToString()
                });

                prevEntity = entity;
            }

            FilteredSearchModel = new List <List <SearchCell> >(SearchModel);
            FilteredTitles      = new List <SearchTitle>(Titles);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Helper method for custom node adding and removing
        /// </summary>
        public static void AssertAddAndRemoveCustomNode(SearchModel searchModel, string nodeName, string catName, string descr = "Bla",
                                                        string path = "Bla")
        {
            var dummyInfo = new CustomNodeInfo(Guid.NewGuid(), nodeName, catName, descr, path);

            searchModel.Add(dummyInfo);

            var res = searchModel.Search(nodeName).ToList();

            Assert.AreNotEqual(0, res.Count());
            Assert.AreEqual(res[0].Name, nodeName);
            Assert.IsTrue(searchModel.ContainsCategory(catName));

            searchModel.RemoveNodeAndEmptyParentCategory(nodeName);
            res = searchModel.Search(nodeName).ToList();

            Assert.AreEqual(0, res.Count());
            Assert.IsFalse(searchModel.ContainsCategory(catName));
        }
        public async override Task GetEntitiesFromServer()
        {
            List <Task> tasks = new List <Task>();

            Task <List <RefereeModel> > entitiesTask = interactor.GetEntities("api/floorball/referees", "Error during getting referees");

            tasks.Add(entitiesTask);

            await Task.WhenAll(tasks);

            var entities = entitiesTask.Result;

            /*var leagues = leaguesTask.Result;
             * var teams = teamsTask.Result;*/

            RefereeModel prevEntity = null;

            List <SearchCell> searchList = new List <SearchCell>();

            foreach (var entity in entities.OrderBy(e => e.Country).ThenBy(e => e.Name).ThenByDescending(e => e.Number))
            {
                if (prevEntity == null || entity.Country != prevEntity.Country)
                {
                    SearchModel.Add(new List <SearchCell>());
                    Titles.Add(new SearchTitle {
                        MainTitle = AppDelegate.SharedAppDelegate.TextManager.GetText(entity.Country), Subtitle = ""
                    });
                }

                SearchModel.Last().Add(new SearchCell
                {
                    Id          = entity.Id,
                    Title       = entity.Name,
                    Subtitle    = "Match count: " + entity.Number.ToString(),
                    RightDetail = ""
                });

                prevEntity = entity;
            }

            FilteredSearchModel = new List <List <SearchCell> >(SearchModel);
            FilteredTitles      = new List <SearchTitle>(Titles);
        }
Ejemplo n.º 8
0
        public void CanRefactorCustomNodeName()
        {
            var nodeName   = "TheNoodle";
            var catName    = "TheCat";
            var descr      = "TheCat";
            var path       = @"C:\turtle\graphics.dyn";
            var guid1      = Guid.NewGuid();
            var dummyInfo1 = new CustomNodeInfo(guid1, nodeName, catName, descr, path);

            search.Add(dummyInfo1);

            Assert.AreEqual(1, search.SearchDictionary.NumElements);

            var newNodeName = "TheTurtle";
            var newInfo     = new CustomNodeInfo(guid1, newNodeName, catName, descr, path);

            search.Refactor(newInfo);

            Assert.AreEqual(1, search.SearchDictionary.NumElements);

            // search for new name
            var results = search.Search(newNodeName).ToList();

            // results are correct
            Assert.AreEqual(1, results.Count());
            var res1 = results[0];

            Assert.IsAssignableFrom(typeof(CustomNodeSearchElement), res1);
            var node1 = res1 as CustomNodeSearchElement;

            Assert.AreEqual(node1.Guid, guid1);

            // search for old name
            var results1 = search.Search(nodeName);

            // results are correct
            Assert.AreEqual(0, results1.Count());
        }