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 void ReturnNull_WhenPassedIdIsInvalid()
        {
            var            repositoryMock = new Mock <IWhoScoredRepository <League> >();
            var            unitOfWorkMock = new Mock <IUnitOfWork>();
            ILeagueService leagueService  = new LeagueService(repositoryMock.Object, unitOfWorkMock.Object);

            int    invalidLeagueId = 33;
            League resultLeague    = leagueService.GetLeagueById(invalidLeagueId);

            Assert.IsNull(resultLeague);
        }
        public void ReturnCorrectLeague_WhenPassedIdIsValid()
        {
            var repositoryMock = new Mock <IWhoScoredRepository <League> >();
            var unitOfWorkMock = new Mock <IUnitOfWork>();

            League league = new League();

            repositoryMock.Setup(x => x.GetById(It.IsAny <int>())).Returns(league);

            ILeagueService leagueService = new LeagueService(repositoryMock.Object, unitOfWorkMock.Object);
            League         actualLeague  = leagueService.GetLeagueById(It.IsAny <int>());

            Assert.AreSame(league, actualLeague);
        }
Esempio n. 4
0
        private async Task GetLeagueById()
        {
            try
            {
                IsRefreshing = true;
                var response = await LeagueService.GetLeagueById(League.Id);

                Teams        = new ObservableCollection <Models.Team>(response.Teams);
                GameMatches  = new ObservableCollection <GameMatch>(response.GameMatches);
                IsRefreshing = false;

                await GenerateStandings();
            }
            catch (Exception e)
            {
                throw e.InnerException;
            }
        }