public void CallRepositoryMethodOnce() { var mockedRepository = new Mock <IWhoScoredRepository <FootballPlayer> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); IFootballPlayerService footballPlayerService = new FootballPlayerService(mockedRepository.Object, mockedUnitOfWork.Object); footballPlayerService.GetAllFootballPlayers(); mockedRepository.Verify(x => x.GetAll(), Times.Once); }
public void GetAllFootballPlayers() { var mockedRepository = new Mock <IWhoScoredRepository <FootballPlayer> >(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); IEnumerable <FootballPlayer> players = new List <FootballPlayer>() { new FootballPlayer() }; mockedRepository.Setup(x => x.GetAll()).Returns(players); IFootballPlayerService footballPlayerService = new FootballPlayerService(mockedRepository.Object, mockedUnitOfWork.Object); var actualPlayes = footballPlayerService.GetAllFootballPlayers(); CollectionAssert.AreEquivalent(players, actualPlayes); }