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 CallLeageServiceGetAllMethodOnce_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
            leagueService.Verify(l => l.GetAll(), Times.Once);
        }
        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());
        }