public void PassValidModelToPartialView_WhenInoked()
        {
            // arrange
            var teamService    = new Mock <ITeamService>();
            var leagueService  = new Mock <ILeagueService>();
            var fixtureService = new Mock <IFixtureService>();

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

            var leagues = new List <League>()
            {
                new League()
                {
                    Name = "some"
                }
            };

            leagueService.Setup(l => l.GetAll()).Returns(leagues);

            // act
            controller.AddFixture();

            // assert
            controller.WithCallTo(c => c.AddFixture())
            .ShouldRenderPartialView(PartialViews.AddFixtureForUpdate)
            .WithModel <IEnumerable <string> >(m => m.Contains("some"));
        }
        public void ReturnCorrectPartialView_WhenInvoked()
        {
            // arrange
            var teamService    = new Mock <ITeamService>();
            var leagueService  = new Mock <ILeagueService>();
            var fixtureService = new Mock <IFixtureService>();

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

            var leagues = new List <League>()
            {
                new League()
                {
                    Name = "some"
                }
            };

            leagueService.Setup(l => l.GetAll()).Returns(leagues);

            // act
            controller.AddFixture();

            // assert
            controller.WithCallTo(c => c.AddFixture())
            .ShouldRenderPartialView(PartialViews.AddFixtureForUpdate);
        }
        public void PasCorrectViewModelToPartialView_WhenPassedLeagueNameParamIsValid()
        {
            // arrange
            var teamService    = new Mock <ITeamService>();
            var leagueService  = new Mock <ILeagueService>();
            var fixtureService = new Mock <IFixtureService>();

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

            var teams = new List <Team>()
            {
                new Team()
                {
                    Name = "someName"
                }
            };

            teamService.Setup(t => t.GetTeamsByLeague("someName")).Returns(teams);

            // act
            controller.AddFixtureForm("someName");

            // assert
            controller.WithCallTo(c => c.AddFixtureForm("someName"))
            .ShouldRenderPartialView(PartialViews.AddFixtureFormPartial)
            .WithModel <AddFixtureViewModel>(m => m.TeamsNames.Contains("someName"));
        }
        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());
        }