public void CreateCorrectInstanceOfLeagueTablemService_WhenPassedArgumentsAreValid()
        {
            var repositoryMock = new Mock <IWhoScoredRepository <LeagueTable> >();

            ILeagueTableService leagueTableService = new LeagueTableService(repositoryMock.Object);

            Assert.IsInstanceOf <LeagueTableService>(leagueTableService);
        }
        public void CallRepositoryMethodOnce_WhenPassedIdIsValid()
        {
            var repositoryMock = new Mock <IWhoScoredRepository <LeagueTable> >();
            ILeagueTableService leagueTableService = new LeagueTableService(repositoryMock.Object);

            leagueTableService.GetLeagueTableById(It.IsAny <int>());

            repositoryMock.Verify(x => x.GetById(It.IsAny <int>()), Times.Once);
        }
        public void ReturnNull_WhenPassedIdIsInvalid()
        {
            var repositoryMock = new Mock <IWhoScoredRepository <LeagueTable> >();
            ILeagueTableService leagueTableService = new LeagueTableService(repositoryMock.Object);

            int         invalidLeagueTableId = 33;
            LeagueTable resultLeagueTable    = leagueTableService.GetLeagueTableById(invalidLeagueTableId);

            Assert.IsNull(resultLeagueTable);
        }
        public void ReturnCorrectLeagueTable_WhenPassedIdIsValid()
        {
            var repositoryMock = new Mock <IWhoScoredRepository <LeagueTable> >();

            LeagueTable leagueTable = new LeagueTable();

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

            ILeagueTableService leagueTableService = new LeagueTableService(repositoryMock.Object);
            LeagueTable         actualLeagueTable  = leagueTableService.GetLeagueTableById(It.IsAny <int>());

            Assert.AreSame(leagueTable, actualLeagueTable);
        }
예제 #5
0
        public ActionResult Table(int?leagueId)
        {
            if (!leagueId.HasValue)
            {
                var user = System.Web.HttpContext.Current.GetCurrentUser();

                using (var dbContext = new LeagueDataContext())
                {
                    var league = dbContext.Leagues.First(l => l.OrganizerId == user.UserId);
                    leagueId = league.Id;
                }
            }

            var leagueTableService = new LeagueTableService((int)leagueId);
            ICollection <TeamInTableViewModel> model = leagueTableService.ExecuteTableOrderRules();

            return(View(model));
        }
예제 #6
0
 public MatchResultController(LeagueTableService leagueTableService)
 {
     _leagueTableService = leagueTableService;
 }
 public LeagueTableController(LeagueTableService leagueTableService)
 {
     _leagueTableService = leagueTableService;
 }