Example #1
0
        public ActionResult AddFixture(AddFixtureViewModel fixtureModel)
        {
            if (ModelState.IsValid)
            {
                this.fixtureService.Add(fixtureModel.HomeTeamName, fixtureModel.AwayTeamName, fixtureModel.StartTime);
                this.TempData[GlobalConstants.SuccessMessage] = "Fixture is ready to be updated!";
            }

            return(this.RedirectToAction <PanelController>(c => c.Index()));
        }
Example #2
0
        public ActionResult AddFixtureForm(string leagueName)
        {
            var teamsNames = this.teamService
                             .GetTeamsByLeague(leagueName)
                             .Select(t => t.Name);

            var addFixtureModel = new AddFixtureViewModel()
            {
                TeamsNames = teamsNames
            };

            return(this.PartialView(PartialViews.AddFixtureFormPartial, addFixtureModel));
        }
        public void CallFixtureServiceAddMethodWithCorrectModelParameter_WhenModelIsInValidState()
        {
            // arrange
            var teamService    = new Mock <ITeamService>();
            var leagueService  = new Mock <ILeagueService>();
            var fixtureService = new Mock <IFixtureService>();

            var addFixtureViewModel = new AddFixtureViewModel()
            {
                HomeTeamName = "Milan",
                AwayTeamName = "Lazio",
                StartTime    = new System.DateTime(2012, 3, 3),
            };

            var controller = new FixturesController(leagueService.Object, teamService.Object, fixtureService.Object);

            // act
            controller.AddFixture(addFixtureViewModel);

            // assert
            fixtureService.Verify(f => f.Add(addFixtureViewModel.HomeTeamName, addFixtureViewModel.AwayTeamName, addFixtureViewModel.StartTime), Times.Once);
        }
        public void RedicrectToPanelControllerIndex_WhenInvoked()
        {
            // arrange
            var teamService    = new Mock <ITeamService>();
            var leagueService  = new Mock <ILeagueService>();
            var fixtureService = new Mock <IFixtureService>();

            var addFixtureViewModel = new AddFixtureViewModel()
            {
                HomeTeamName = "Milan",
                AwayTeamName = "Lazio",
                StartTime    = new System.DateTime(2012, 3, 3),
            };

            var controller = new FixturesController(leagueService.Object, teamService.Object, fixtureService.Object);

            // act
            controller.AddFixture(addFixtureViewModel);

            // assert
            controller.WithCallTo(c => c.AddFixture(addFixtureViewModel))
            .ShouldRedirectTo <PanelController>(c => c.Index());
        }