public void CallRepositoryMethodOnce() { var repositoryMock = new Mock <IWhoScoredRepository <League> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); ILeagueService leagueService = new LeagueService(repositoryMock.Object, unitOfWorkMock.Object); leagueService.GetAlLeagues(); repositoryMock.Verify(x => x.GetAll(), Times.Once); }
public void GetAllLeagues() { var repositoryMock = new Mock <IWhoScoredRepository <League> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); ILeagueService leagueService = new LeagueService(repositoryMock.Object, unitOfWorkMock.Object); IEnumerable <League> leagues = new List <League>(); repositoryMock.Setup(x => x.GetAll()).Returns(leagues); IEnumerable <League> actualLeagues = leagueService.GetAlLeagues(); CollectionAssert.AreEquivalent(leagues, actualLeagues); }