Exemplo n.º 1
0
        public void PlayerService_GetForLeague_ValidLeagueNoPlayers()
        {
            //Arrange
            var mockLeagueRepo = new MockLeagueRepository().MockIsValid(true);

            var mockPlayerRepo = new MockPlayerRepository().MockGetForTeam(new List <Player>());

            var mockTeams = new List <Team>()
            {
                new Team()
                {
                    ID = 1
                }
            };

            var mockTeamRepo = new MockTeamRepository().MockGetForLeague(mockTeams);

            var playerService = new PlayerService(mockPlayerRepo.Object,
                                                  mockTeamRepo.Object,
                                                  mockLeagueRepo.Object);

            //Act
            var allPlayers = playerService.GetForLeague(1);

            //Assert
            Assert.Empty(allPlayers);
            mockPlayerRepo.VerifyGetForTeam(Times.AtLeastOnce());
            mockTeamRepo.VerifyGetForLeague(Times.Once());
            mockLeagueRepo.VerifyIsValid(Times.Once());
        }
Exemplo n.º 2
0
        public void PlayerService_GetForLeague_InvalidLeague()
        {
            //Arrange
            var mockLeagueRepo = new MockLeagueRepository().MockIsValid(false);

            var playerService = new PlayerService(new MockPlayerRepository().Object,
                                                  new MockTeamRepository().Object,
                                                  mockLeagueRepo.Object);

            //Act
            var allPlayers = playerService.GetForLeague(1);

            //Assert
            Assert.Empty(allPlayers);
            mockLeagueRepo.VerifyIsValid(Times.Once());
        }
Exemplo n.º 3
0
        public void TeamService_Search_NewerThan_Invalid()
        {
            var mockTeams = GetMockTeams();

            var mockTeamRepo   = new MockTeamRepository().MockGetForLeague(mockTeams);
            var mockLeagueRepo = new MockLeagueRepository().MockIsValid(true);

            var teamService = new TeamService(mockTeamRepo.Object, mockLeagueRepo.Object);

            var searchParams = new TeamSearch()
            {
                LeagueID     = 1,
                FoundingDate = new DateTime(2017, 1, 1),
                Direction    = SearchDateDirection.NewerThan
            };

            //Act
            var results = teamService.Search(searchParams);

            Assert.Empty(results);
            mockLeagueRepo.VerifyIsValid(Times.Once());
            mockTeamRepo.VerifyGetForLeague(Times.Once());
        }