コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }