public void TestSetup()
        {
            this.mockedPlayerService = new Mock <IPlayerService>();
            this.mockedTeamService   = new Mock <ITeamService>();
            this.mockedMapper        = new Mock <IMapperAdapter>();

            this.controller = new AddPlayerController(
                mockedPlayerService.Object,
                mockedTeamService.Object);
        }
        public void ReturnViewResultWithCorrectModelType()
        {
            // Arrange
            var mockedPlayerService = new Mock <IPlayerService>();
            var mockedTeamService   = new Mock <ITeamService>();

            mockedTeamService.Setup(x => x.GetAllTeams()).Returns(new List <Team>());

            var controller = new AddPlayerController(mockedPlayerService.Object, mockedTeamService.Object);

            // Act
            var result = controller.Index() as ViewResult;

            // Assert
            Assert.IsInstanceOf <AddPlayerViewModel>(result.Model);
        }
        public void ReturnViewResult_WithCorrectTeam()
        {
            // Arrange
            var mockedPlayerService = new Mock <IPlayerService>();
            var mockedTeamService   = new Mock <ITeamService>();
            var teams = new List <Team>()
            {
                new Team()
                {
                    Id = 1, Name = "Barca"
                },
                new Team()
                {
                    Id = 2, Name = "Real Madrid"
                },
                new Team()
                {
                    Id = 3, Name = "Liechtenstein"
                }
            };

            mockedTeamService.Setup(x => x.GetAllTeams()).Returns(teams);

            var controller = new AddPlayerController(mockedPlayerService.Object, mockedTeamService.Object);

            // Act
            var result = (ViewResult)controller.Index();

            // Assert
            var model      = (AddPlayerViewModel)result.Model;
            var selectList = model.Teams.ToList();

            Assert.AreEqual(teams.Count, selectList.Count);
            for (int i = 0; i < teams.Count; i++)
            {
                Assert.AreEqual(teams[i].Id.ToString(), selectList[i].Value);
                Assert.AreEqual(teams[i].Name, selectList[i].Text);
            }
        }