示例#1
0
        public void EightTournamentsInCategory()
        {
            TestGroupVw soccerCategory = new TestGroupVw()
            {
                DisplayName = "soccer category", LineObject = new GroupLn()
                {
                    GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                    {
                        Value = 1
                    }
                }
            };
            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();

            collection = FillCategoryWithTournaments(soccerCategory, 8);

            ChangeTracker.Setup(x => x.SelectedTournaments).Returns(new HashSet <string>());
            TranslationProvider.Setup(x => x.Translate(It.IsAny <MultistringTag>())).Returns("Outrights");
            Repository.Setup(x => x.FindMatches(It.IsAny <SortableObservableCollection <IMatchVw> >(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <LineSr.DelegateFilterMatches>(), It.IsAny <Comparison <IMatchVw> >())).Returns(collection);

            TopTournamentsViewModel model = new TopTournamentsViewModel();

            model.OnNavigationCompleted();

            //no outrights, without "all tournaments"
            Assert.AreEqual(1, model.Categories.Count);
            Assert.AreEqual("soccer category", model.Categories[0].SportName);
            Assert.AreEqual(8, model.Categories[0].Tournaments.Count);
            Assert.AreEqual("tournament0", model.Categories[0].Tournaments[0].Name);
            Assert.AreEqual("tournament7", model.Categories[0].Tournaments[7].Name);
        }
示例#2
0
        private SortableObservableCollection <IMatchVw> FillCategoryWithTournaments(TestGroupVw category, int amount)
        {
            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();

            for (int i = 0; i < amount; i++)
            {
                collection.Add(new TestMatchVw()
                {
                    SportDescriptor = "SPRT_SOCCER",
                    DefaultSorting  = i,
                    IsLiveBet       = false,
                    IsOutright      = false,
                    Name            = "test1",
                    CategoryView    = category,
                    SportView       = new TestGroupVw()
                    {
                        DisplayName = "s", LineObject = new GroupLn()
                        {
                            GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                            {
                                Value = 3
                            }
                        }
                    },
                    StartDate      = new DateTime(2015, 1, 2),
                    TournamentView = new TestGroupVw()
                    {
                        DisplayName = "tournament" + i.ToString(), LineObject = new GroupLn()
                        {
                            GroupId = i, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                            {
                                Value = i
                            }
                        }
                    },
                    ExpiryDate = DateTime.Now.AddDays(365)
                });
            }

            return(collection);
        }
示例#3
0
        private IMatchVw CreateMatch(int index, bool outright = false)
        {
            TestGroupVw tournamentView = new TestGroupVw()
            {
                DisplayName = "test" + index,
            };

            tournamentView.LineObject = new GroupLn()
            {
                GroupId = index,
            };
            var match = new TestMatchVw()
            {
                TournamentView = tournamentView,
                StartDate      = DateTime.Now.AddDays(5),
                ExpiryDate     = DateTime.Now.AddDays(5),
                IsOutright     = outright,
            };

            return(match);
        }
示例#4
0
        public void SearchViewModelSortingTest()
        {
            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();

            collection.Add(new TestMatchVw()
            {
                IsLiveBet       = true,
                TournamentView  = TestGroupVw.CreateGroup(1, false),
                LiveBetStatus   = eMatchStatus.Started,
                LiveMatchMinute = 1,
                LivePeriodInfo  = eLivePeriodInfo.Basketball_1st_Quarter,
                Name            = "test1",
                SportView       = new TestGroupVw()
                {
                    DisplayName = "b", LineObject = new GroupLn()
                    {
                        Sort = { Value = 3 }
                    }
                },
                StartDate = new DateTime(2013, 1, 1)
            });
            collection.Add(new TestMatchVw()
            {
                IsLiveBet       = true,
                TournamentView  = TestGroupVw.CreateGroup(1, false),
                LiveBetStatus   = eMatchStatus.Started,
                LiveMatchMinute = 1,
                LivePeriodInfo  = eLivePeriodInfo.Basketball_1st_Quarter,
                Name            = "test2",
                SportView       = new TestGroupVw()
                {
                    DisplayName = "s", LineObject = new GroupLn()
                    {
                        Sort = { Value = 1 }
                    }
                },
                StartDate = new DateTime(2013, 1, 2)
            });
            collection.Add(new TestMatchVw()
            {
                IsLiveBet       = true,
                TournamentView  = TestGroupVw.CreateGroup(1, false),
                LiveBetStatus   = eMatchStatus.Started,
                LiveMatchMinute = 1,
                LivePeriodInfo  = eLivePeriodInfo.Basketball_1st_Quarter,
                Name            = "test3",
                SportView       = new TestGroupVw()
                {
                    DisplayName = "h", LineObject = new GroupLn()
                    {
                        Sort = { Value = 4 }
                    }
                },
                StartDate = new DateTime(2013, 1, 3)
            });
            collection.Add(new TestMatchVw()
            {
                IsLiveBet       = true,
                TournamentView  = TestGroupVw.CreateGroup(1, false),
                LiveBetStatus   = eMatchStatus.Started,
                LiveMatchMinute = 1,
                LivePeriodInfo  = eLivePeriodInfo.Basketball_1st_Quarter,
                Name            = "test4",
                SportView       = new TestGroupVw()
                {
                    DisplayName = "t", LineObject = new GroupLn()
                    {
                        Sort = { Value = 2 }
                    }
                },
                StartDate = new DateTime(2013, 1, 4)
            });


            collection.Sort(SearchViewModel.Comparison);

            Assert.AreEqual("test1", collection[0].Name);
            Assert.AreEqual("test2", collection[1].Name);
            Assert.AreEqual("test3", collection[2].Name);
            Assert.AreEqual("test4", collection[3].Name);
        }
示例#5
0
        public void CetagoriesWithOnlyOutrights()
        {
            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();
            TestGroupVw soccerCategory = new TestGroupVw()
            {
                DisplayName = "soccer category", LineObject = new GroupLn()
                {
                    GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                    {
                        Value = 1
                    }
                }
            };

            ChangeTracker.Setup(x => x.SelectedTournaments).Returns(new HashSet <string>());
            TranslationProvider.Setup(x => x.Translate(It.IsAny <MultistringTag>())).Returns("Outrights");
            Repository.Setup(x => x.FindMatches(It.IsAny <SortableObservableCollection <IMatchVw> >(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <LineSr.DelegateFilterMatches>(), It.IsAny <Comparison <IMatchVw> >())).Returns(collection);

            //add outright tournament to category
            collection.Add(new TestMatchVw()
            {
                SportDescriptor = "SPRT_SOCCER",
                DefaultSorting  = 1,
                IsLiveBet       = false,
                IsOutright      = true,
                LiveBetStatus   = eMatchStatus.NotStarted,
                Name            = "outright1",
                SportView       = new TestGroupVw()
                {
                    DisplayName = "soccer", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                CategoryView   = soccerCategory,
                StartDate      = new DateTime(2015, 1, 2),
                TournamentView = new TestGroupVw()
                {
                    DisplayName         = "outright1",
                    TournamentSportView = new TestGroupVw()
                    {
                        DisplayName = "lasttournament", LineObject = new GroupLn()
                        {
                            GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                            {
                                Value = 1
                            }
                        }
                    },
                    LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                ExpiryDate = DateTime.Now.AddDays(1000)
            });

            TopTournamentsViewModel model = new TopTournamentsViewModel();

            model.OnNavigationCompleted();

            //we do not show categories with outrights only
            Assert.AreEqual(0, model.Categories.Count);
        }
示例#6
0
        public void FillSeveralCategories()
        {
            TestGroupVw soccerCategory = new TestGroupVw()
            {
                DisplayName = "soccer category", LineObject = new GroupLn()
                {
                    GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                    {
                        Value = 1
                    }
                }
            };
            TestGroupVw hockeyCategory = new TestGroupVw()
            {
                DisplayName = "hockey category", LineObject = new GroupLn()
                {
                    GroupId = 3, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                    {
                        Value = 3
                    }
                }
            };
            TestGroupVw someCategory = new TestGroupVw()
            {
                DisplayName = "some category", LineObject = new GroupLn()
                {
                    GroupId = 2, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                    {
                        Value = 2
                    }
                }
            };

            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();

            collection = FillCategoryWithTournaments(soccerCategory, 8);

            SortableObservableCollection <IMatchVw> collection2 = FillCategoryWithTournaments(hockeyCategory, 15);
            SortableObservableCollection <IMatchVw> collection3 = FillCategoryWithTournaments(someCategory, 2);

            foreach (IMatchVw m in collection2)
            {
                collection.Add(m);
            }

            foreach (IMatchVw m in collection3)
            {
                collection.Add(m);
            }

            ChangeTracker.Setup(x => x.SelectedTournaments).Returns(new HashSet <string>());
            TranslationProvider.Setup(x => x.Translate(It.IsAny <MultistringTag>())).Returns("Outrights");
            Repository.Setup(x => x.FindMatches(It.IsAny <SortableObservableCollection <IMatchVw> >(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <LineSr.DelegateFilterMatches>(), It.IsAny <Comparison <IMatchVw> >())).Returns(collection);

            TopTournamentsViewModel model = new TopTournamentsViewModel();

            model.OnNavigationCompleted();

            Assert.AreEqual(3, model.Categories.Count);
            Assert.AreEqual("soccer category", model.Categories[0].SportName);
            Assert.AreEqual("hockey category", model.Categories[2].SportName);
            Assert.AreEqual("some category", model.Categories[1].SportName);
            Assert.AreEqual(8, model.Categories[0].Tournaments.Count);
            Assert.AreEqual(8, model.Categories[2].Tournaments.Count);
            Assert.AreEqual(2, model.Categories[1].Tournaments.Count);
            Assert.AreEqual("tournament0", model.Categories[0].Tournaments[0].Name);
            Assert.AreEqual("tournament7", model.Categories[0].Tournaments[7].Name);
            Assert.AreEqual("All tournaments", model.Categories[2].Tournaments[7].Name);
            Assert.AreEqual("tournament0", model.Categories[0].Tournaments[0].Name);
            Assert.AreEqual("tournament1", model.Categories[0].Tournaments[1].Name);
        }
示例#7
0
        public void FillPlentyTournamentsWithOutrights()
        {
            ChangeTracker.Setup(x => x.SelectedTournaments).Returns(new HashSet <string>());
            TranslationProvider.Setup(x => x.Translate(It.IsAny <MultistringTag>())).Returns("Outrights");

            SortableObservableCollection <IMatchVw> collection = new SortableObservableCollection <IMatchVw>();

            TestGroupVw soccerCategory = new TestGroupVw()
            {
                DisplayName = "soccer category", LineObject = new GroupLn()
                {
                    GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                    {
                        Value = 1
                    }
                }
            };

            //get category with more tournaments that fits into it
            collection = FillCategoryWithTournaments(soccerCategory, 9);

            //add outright tournament to category
            collection.Add(new TestMatchVw()
            {
                SportDescriptor = "SPRT_SOCCER",
                DefaultSorting  = 1,
                IsLiveBet       = false,
                IsOutright      = true,
                LiveBetStatus   = eMatchStatus.NotStarted,
                Name            = "outright1",
                SportView       = new TestGroupVw()
                {
                    DisplayName = "soccer", LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                CategoryView   = soccerCategory,
                StartDate      = new DateTime(2015, 1, 2),
                TournamentView = new TestGroupVw()
                {
                    DisplayName         = "outright1",
                    TournamentSportView = new TestGroupVw()
                    {
                        DisplayName = "lasttournament", LineObject = new GroupLn()
                        {
                            GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                            {
                                Value = 1
                            }
                        }
                    },
                    LineObject = new GroupLn()
                    {
                        GroupId = 1, Sort = new ObservableProperty <int>(new GroupLn(), new ObservablePropertyList(), "test")
                        {
                            Value = 1
                        }
                    }
                },
                ExpiryDate = DateTime.Now.AddDays(1000)
            });

            Repository.Setup(x => x.FindMatches(It.IsAny <SortableObservableCollection <IMatchVw> >(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <LineSr.DelegateFilterMatches>(), It.IsAny <Comparison <IMatchVw> >())).Returns(collection);
            TopTournamentsViewModel model = new TopTournamentsViewModel();

            model.OnNavigationCompleted();

            //no outrights, with "all tournaments"
            Assert.AreEqual(1, model.Categories.Count);
            Assert.AreEqual("soccer category", model.Categories[0].SportName);
            Assert.AreEqual(8, model.Categories[0].Tournaments.Count);
            Assert.AreEqual("tournament0", model.Categories[0].Tournaments[0].Name);
            Assert.AreEqual("tournament6", model.Categories[0].Tournaments[6].Name);
            Assert.AreEqual("All tournaments", model.Categories[0].Tournaments[7].Name);
        }