Beispiel #1
0
        public void CreateMatches_IfLeagueHasMatches_ReturnCollectionOfMatches()
        {
            var teamService = new Mock <ITeamService>();
            var handler     = new Mock <IMatchHandler>();
            var match       = new Mock <Match>();
            var options     = TestUtils.GetOptions(nameof(CreateMatches_IfLeagueHasMatches_ReturnCollectionOfMatches));
            var league      = new League()
            {
                Name = "l"
            };
            var matchesMock = new List <Match>()
            {
                match.Object
            };

            handler.Setup(h => h.CreateMatches(league)).Returns(matchesMock);
            using (var arrangeContext = new FMDbContext(options))
            {
                arrangeContext.Leagues.Add(league);
                arrangeContext.SaveChanges();
            }
            using (var assertContext = new FMDbContext(options))
            {
                var sut     = new LeagueService(assertContext, teamService.Object, handler.Object);
                var matches = sut.CreateMatches("l");
                Assert.AreEqual(0, matches.Count());
            }
        }
Beispiel #2
0
        public void CallLeaguesRepoUpdateMethodWithCorrectLeagueObject_WhenProvideLeagueHasValidNewNameAndSeason()
        {
            // arrange
            var leaguesRepo   = new Mock <IEfRepository <League> >();
            var countriesRepo = new Mock <IEfRepository <Country> >();

            var league = new League()
            {
                Name = "someName", Id = Guid.NewGuid(), Season = 2017
            };

            leaguesRepo.Setup(lr => lr.All).Returns(new List <League>()
            {
                league
            }.AsQueryable());

            var updateLeague = new League()
            {
                Name = "someName", Id = league.Id, Season = 2010
            };
            var leagueService = new LeagueService(leaguesRepo.Object, countriesRepo.Object);

            // act
            leagueService.Update(updateLeague);

            // assert
            leaguesRepo.Verify(lr => lr.Update(It.Is <League>(l => l.Name == updateLeague.Name && l.Season == updateLeague.Season)));
        }
Beispiel #3
0
        private LeagueService CreateLeagueService()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new LeagueService(userId);

            return(service);
        }
        protected override void OnLoad(EventArgs e)
        {
            Panel noLeaguePanel = (Panel)base.Master.FindControl("noleague_panel");

            if (noLeaguePanel != null)
            {
                noLeaguePanel.Visible = !IsLeagueSelected;
            }

            if (!Page.IsPostBack)
            {
                DropDownList leagueList = (DropDownList)base.Master.FindControl("league_list");
                if (leagueList != null)
                {
                    leagueList.Visible = true;

                    leagueList.DataSource = LeagueService.GetActiveLeagues();
                    leagueList.DataBind();
                    leagueList.Items.Insert(0, new ListItem("-- Choose a League --", ""));
                    leagueList.SelectedIndex = 0;

                    if (CurrentLeagueId > 0)
                    {
                        leagueList.SelectedValue = CurrentLeagueId.ToString();
                    }
                }
            }

            base.OnLoad(e);
        }
Beispiel #5
0
        protected void BindStandingsGrid()
        {
            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["default"].ConnectionString))
            {
                connection.Open();

                using (SqlCommand cmd = new SqlCommand("User_GetStandings", connection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(new SqlParameter("LeagueId", base.CurrentLeagueId));

                    IDataReader data = cmd.ExecuteReader();
                    standings_grid.DataSource = data;
                    standings_grid.DataBind();
                    try { standings_grid.HeaderRow.TableSection = TableRowSection.TableHeader; }
                    catch { }
                    data.Close();
                }

                connection.Close();
            }

            var groupings = LeagueService.ListTournamentGroupings(this.CurrentLeagueId);

            groupings_list.DataSource = groupings;
            groupings_list.DataBind();
        }
Beispiel #6
0
        public void SetUp()
        {
            dbContext    = DbContextUtility.CreateMockDb();
            pointService = Substitute.For <IPointService>();

            testObj = new LeagueService(dbContext, pointService);
        }
Beispiel #7
0
        // private Lua luaState;


        // TODO
        // add char and league service to singleton
        public PoeFetcherManager(ILogger <PoeFetcherManager> logger)
        {
            _logger               = logger;
            this.PoeContext       = new PoeDbContext();
            this.characterService = new CharacterService(this.PoeContext);
            this.leagueService    = new LeagueService(this.PoeContext);
        }
Beispiel #8
0
        protected void BindLeagueGrid()
        {
            var leagues = LeagueService.GetActiveLeagues();

            league_grid.DataSource = leagues;
            league_grid.DataBind();
        }
        public void ShouldGetByName()
        {
            var leagueRepoMock = new Mock <ILeagueRepository>();

            leagueRepoMock.Setup(p => p.GetByName("NHL")).Returns(
                new League()
            {
                Name               = "NHL",
                FirstYear          = 1,
                LastYear           = null,
                Id                 = 1,
                CompetitionConfigs = new List <CompetitionConfig>()
                {
                    new SeasonCompetitionConfig()
                    {
                        Id = 5
                    }, new PlayoffCompetitionConfig()
                    {
                        Id = 15
                    }
                }
            }
                );

            var leagueService = new LeagueService(leagueRepoMock.Object);

            var league = leagueService.GetByName("NHL");

            True(league is LeagueViewModel);
            Equals("NHL", league.Name);
            StrictEqual(1, league.Id);
            StrictEqual(1, league.FirstYear);
            Null(league.LastYear);
        }
Beispiel #10
0
 protected override void OnInitialized()
 {
     if (Leagues == null)
     {
         Leagues = LeagueService.GetAll().ToList();
     }
 }
Beispiel #11
0
        public MatchProtocolPage(Match match)
        {
            InitializeComponent();
            _leagueService = new LeagueService();

            var league = _leagueService.GetAll().First(x => x.TeamIds.Contains(match.HomeTeamId));

            LeagueName.Text = league.Name.Value;
            var teamService       = new TeamService();
            var matchEventService = new MatchEventService();

            var homeTeamEvents = match.MatchEventIds
                                 .Select(matchEventService.FindById)
                                 .Where(mEvent => match.HomeTeamSquadId.Contains(mEvent.PlayerId));

            var awayTeamEvents = match.MatchEventIds
                                 .Select(matchEventService.FindById)
                                 .Where(mEvent => match.AwayTeamSquadId.Contains(mEvent.PlayerId));

            var homeTeamGoals = homeTeamEvents.Where(e => e.GetType() == MatchEvents.Goal);
            var awayTeamGoals = awayTeamEvents.Where(e => e.GetType() == MatchEvents.Goal);


            ShowDate.Text = match.MatchDate.ToString("dd-MM-yy");
            //MatchWeek.Text = matchWeek.ToString();
            HomeTeamName.Text  = teamService.FindById(match.HomeTeamId).Name.Value;
            AwayTeamName.Text  = teamService.FindById(match.AwayTeamId).Name.Value;
            HomeTeamGoals.Text = homeTeamGoals.ToList().Count.ToString();
            AwayTeamGoals.Text = awayTeamGoals.ToList().Count.ToString();
            HomeTeamMatchEvents.ItemsSource = homeTeamEvents;
            AwayTeamMatchEvents.ItemsSource = awayTeamEvents;
        }
Beispiel #12
0
 public RiotClient(string apiKey)
 {
     Summoner  = new SummonerService(apiKey);
     League    = new LeagueService(apiKey);
     Masteries = new MasteryService(apiKey);
     Specate   = new SpecateService(apiKey);
 }
Beispiel #13
0
        public void ThrowInvalidOperationException_WhenLeagueForTheProvidedSeasonAlreadyExists()
        {
            // arrange
            var leaguesRepo   = new Mock <IEfRepository <League> >();
            var countriesRepo = new Mock <IEfRepository <Country> >();

            var leagueService = new LeagueService(leaguesRepo.Object, countriesRepo.Object);

            var country = new Country()
            {
                Name = "someName"
            };
            var league = new League()
            {
                Country = country, Season = 2017
            };

            countriesRepo.Setup(cr => cr.All).Returns(new List <Country>()
            {
                country
            }.AsQueryable());
            leaguesRepo.Setup(l => l.All).Returns(new List <League>()
            {
                league
            }.AsQueryable());

            // act & assert
            Assert.Throws <InvalidOperationException>(() => leagueService.Add(league));
        }
Beispiel #14
0
        public LeaguesController(PoeDbContext context, LeagueService _leagueService, IDistributedCache distributedCache, ILogger <LeaguesController> logger)
        {
            PoeContext            = context;
            this.distributedCache = distributedCache;
            this._logger          = logger;
            this.leagueService    = _leagueService;

            // TODO
            // move to Startup file or dbcontext?
            SqlMapper.AddTypeHandler <PoeAccount>(new JsonConvertHandler <PoeAccount>());

            SqlMapper.AddTypeHandler <List <CharEntry> >(new JsonConvertHandler <List <CharEntry> >());
            SqlMapper.AddTypeHandler <List <UniqueEntry> >(new JsonConvertHandler <List <UniqueEntry> >());
            SqlMapper.AddTypeHandler <List <SkillEntry> >(new JsonConvertHandler <List <SkillEntry> >());
            SqlMapper.AddTypeHandler <List <KeystoneEntry> >(new JsonConvertHandler <List <KeystoneEntry> >());
            SqlMapper.AddTypeHandler <List <WeaponTypeEntry> >(new JsonConvertHandler <List <WeaponTypeEntry> >());
            SqlMapper.AddTypeHandler <List <ClassEntry> >(new JsonConvertHandler <List <ClassEntry> >());

            SqlMapper.AddTypeHandler <CharEntry[]>(new JsonConvertHandler <CharEntry[]>());
            SqlMapper.AddTypeHandler <UniqueEntry[]>(new JsonConvertHandler <UniqueEntry[]>());
            SqlMapper.AddTypeHandler <SkillEntry[]>(new JsonConvertHandler <SkillEntry[]>());
            SqlMapper.AddTypeHandler <KeystoneEntry[]>(new JsonConvertHandler <KeystoneEntry[]>());
            SqlMapper.AddTypeHandler <WeaponTypeEntry[]>(new JsonConvertHandler <WeaponTypeEntry[]>());
            SqlMapper.AddTypeHandler <ClassEntry[]>(new JsonConvertHandler <ClassEntry[]>());
            SqlMapper.AddTypeHandler <MainSkillSupportCountEntry[]>(new JsonConvertHandler <MainSkillSupportCountEntry[]>());
        }
Beispiel #15
0
 public AuthController(UserManager <PickEmUser> userManager, LeagueService leagueService, IOptions <JwtConfig> jwtOptions, ILogger <AuthController> logger)
 {
     _userManager   = userManager;
     _leagueService = leagueService;
     _logger        = logger;
     _jwtOptions    = jwtOptions.Value;
 }
        public CreateLeaguePage(bool isEdit, League league)
        {
            InitializeComponent();
            DataContext              = this;
            _leagueService           = new LeagueService();
            _teamService             = new TeamService();
            _personService           = new PersonService();
            Teams                    = new ObservableCollection <Team>();
            AddTeamBtn.Visibility    = Visibility.Collapsed;
            RemoveTeamBtn.Visibility = Visibility.Collapsed;
            foreach (var teamId in league.TeamIds)
            {
                Teams.Add(_teamService.FindById(teamId));
            }
            TeamList.ItemsSource = Teams;

            if (isEdit)
            {
                SaveEditLeagueBtn.Visibility = Visibility.Visible;
                AddLeagueButton.Visibility   = Visibility.Hidden;
            }
            else
            {
                SaveEditLeagueBtn.Visibility = Visibility.Hidden;
                AddLeagueButton.Visibility   = Visibility.Visible;
            }
        }
Beispiel #17
0
        public IHttpActionResult Get()
        {
            LeagueService service = CreateLeagueService();
            var           leagues = service.GetAllLeagues();

            return(Ok(leagues));
        }
        public void ReturnsLeagues()
        {
            //Arrange

            var service     = new Mock <TeamService>();
            var teamService = new Mock <ITeamService>();
            var handler     = new Mock <IMatchHandler>();
            var options     = TestUtils.GetOptions(nameof(ReturnsLeagues));

            using (var arrangeContext = new FMDbContext(options))
            {
                var league = new League()
                {
                    Name = "Test",
                    Id   = 1
                };
                arrangeContext.Leagues.Add(league);
                arrangeContext.SaveChanges();
            }
            //Act,Assert
            using (var assertContext = new FMDbContext(options))
            {
                var sut     = new LeagueService(assertContext, teamService.Object, handler.Object);
                var leagues = sut.ShowAllLeagues().ToList();
                Assert.AreEqual(leagues.Count(), 1);
                Assert.AreEqual(leagues[0].Name, "Test");
            }
        }
Beispiel #19
0
        // GET: League
        public ActionResult Index()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new LeagueService(userId);
            var model   = service.GetLeagues();

            return(View(model));
        }
        public async Task <IActionResult> Match(MatchService matchService, LeagueService leagueService, string matchId, string flagUrl, bool matchFinished)
        {
            Match match = await matchService.getMatch(matchId, flagUrl);

            MatchViewModel viewModel = new MatchViewModel(match);

            return(View(viewModel));
        }
Beispiel #21
0
        public void SetupQuickPlayGame(object sender, EventArgs args)
        {
            //TODO: replace with proper league settings
            ILeagueService leagueService = new LeagueService();
            var            league        = leagueService.GetGenericLeague();

            Navigation.PushModalAsync(new NavigationPage(new Game.SetupGamePage(league.LeagueId)));
        }
Beispiel #22
0
        public async Task FilterLeaguesAsync_ShouldReturnItems_WhenPassedValidParameters()
        {
            // Arrange
            var contextOptions = new DbContextOptionsBuilder <DataContext>()
                                 .UseInMemoryDatabase(databaseName: "FilterLeaguesAsync_ShouldReturnItems_WhenPassedValidParameters")
                                 .Options;

            string validSortOrder  = "name_asc";
            string validFilter     = "testLeague";
            int    validPageSize   = 10;
            int    validPageNumber = 1;

            string validFirstName     = "testLeague";
            string validSlug          = "validSlug";
            bool   validLifeSupported = true;

            League validLeague = new League
            {
                Name          = validFirstName,
                Slug          = validSlug,
                LifeSupported = validLifeSupported
            };

            IEnumerable <League> result = new List <League>();

            // Act
            using (DataContext actContext = new DataContext(contextOptions))
            {
                Mock <IPandaScoreClient> pandaScoreClientMock = new Mock <IPandaScoreClient>();

                await actContext.Leagues.AddAsync(validLeague);

                await actContext.SaveChangesAsync();

                LeagueService SUT = new LeagueService(
                    pandaScoreClientMock.Object,
                    actContext);

                result = await SUT.FilterLeaguesAsync(validSortOrder, validFilter, validPageNumber, validPageSize);

                Assert.IsTrue(result.Count() == 1);
                Assert.IsTrue(result.ToArray()[0].Name.Equals(validFirstName));
                Assert.IsTrue(result.ToArray()[0].Slug == validSlug);
                Assert.IsTrue(result.ToArray()[0].LifeSupported == true);
            }

            // Assert
            using (DataContext assertContext = new DataContext(contextOptions))
            {
                var league = result.ToArray()[0];

                Assert.IsTrue(assertContext.Leagues.Count().Equals(result.Count()));
                Assert.IsTrue(assertContext.Leagues.Any(l => l.Name.Equals(league.Name)));
                Assert.IsTrue(assertContext.Leagues.Any(l => l.Slug.Equals(league.Slug)));
                Assert.IsTrue(assertContext.Leagues.Any(l => l.LifeSupported.Equals(league.LifeSupported)));
            }
        }
        protected override void OnInitialized()
        {
            if (Competitions == null)
            {
                Competitions = LeagueService.GetCompetitionConfigs(SelectedLeague.Id).ToList();
            }

            DropDownState.OnChange += StateHasChanged;
        }
        public LeagueController()
        {
            var modelContainer = new ModelContainer();

            _footballDataApiClient = new FootballDataApiClient();
            _leagueService         = new LeagueService(new GenericRepository <League>(modelContainer));
            _teamService           = new TeamService(new GenericRepository <Team>(modelContainer));
            _playerService         = new PlayerService(new GenericRepository <Player>(modelContainer));
        }
Beispiel #25
0
        public void CreateCorrectInstanceOfLeagueService_WhenPassedArgumentsAreValid()
        {
            var repositoryMock = new Mock <IWhoScoredRepository <League> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();

            ILeagueService leagueService = new LeagueService(repositoryMock.Object, unitOfWorkMock.Object);

            Assert.IsInstanceOf <LeagueService>(leagueService);
        }
        public async Task <IActionResult> Leagues(LeagueService leagueService, int leagueCode = 2021, int leagueTypeCode = 0)
        {
            LeaguesViewModel   viewModel = new LeaguesViewModel(leagueCode, leagueTypeCode);
            List <LeagueEntry> leagues   = await leagueService.getLeagueTable(leagueCode, leagueTypeCode);

            viewModel.leagues          = leagues;
            viewModel.shortLeagueTitle = leagueService.shortLeagueName;
            viewModel.longLeagueTitle  = leagueService.longLeagueName;
            return(View(viewModel));
        }
        public void CallRepositoryMethodOnce()
        {
            var            repositoryMock = new Mock <IWhoScoredRepository <League> >();
            var            unitOfWorkMock = new Mock <IUnitOfWork>();
            ILeagueService leagueService  = new LeagueService(repositoryMock.Object, unitOfWorkMock.Object);

            leagueService.GetAlLeagues();

            repositoryMock.Verify(x => x.GetAll(), Times.Once);
        }
 private void Init()
 {
     Champion = new ChampionService(LeagueApiConfiguration);
     Game     = new GameService(LeagueApiConfiguration);
     League   = new LeagueService(LeagueApiConfiguration);
     Stats    = new StatsService(LeagueApiConfiguration);
     Summoner = new SummonerService(LeagueApiConfiguration);
     Team     = new TeamService(LeagueApiConfiguration);
     Static   = new StaticService(LeagueApiConfiguration);
 }
        public void CallRepositoryMethodOnce_WhenPassedIdIsValid()
        {
            var            repositoryMock = new Mock <IWhoScoredRepository <League> >();
            var            unitOfWorkMock = new Mock <IUnitOfWork>();
            ILeagueService leagueService  = new LeagueService(repositoryMock.Object, unitOfWorkMock.Object);

            leagueService.GetLeagueById(It.IsAny <int>());

            repositoryMock.Verify(x => x.GetById(It.IsAny <int>()), Times.Once);
        }
 public PlayerStatsPage(IEnumerable <Team> teams)
 {
     DataContext = this;
     InitializeComponent();
     SubHeader.Visibility = Visibility.Collapsed;
     PlayersDataGrid.AutoGenerateColumns = false;
     PlayersDataGrid.ItemsSource         = SortingAlgorithm.Sort(teams, SortingAlgorithm.PlayerSortByTypes.Goal, true);
     _leagueService = new LeagueService();
     Header.Text    = _leagueService.GetAll().First(x => x.TeamIds.Contains(teams.First().Id)).Name.Value;
 }