Exemplo n.º 1
0
        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"));
        }
Exemplo n.º 2
0
        public void CallTeamServiceGetByLeaguNameWithValidTheCorrectLeagueName_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
            teamService.Verify(t => t.GetTeamsByLeague("someName"), Times.Once);
        }