public void CallUnitOfWorkCommitMethodOnce() { var leagueMock = new Mock <League>(); var repositoryMock = new Mock <IWhoScoredRepository <League> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); ILeagueService leagueService = new LeagueService(repositoryMock.Object, unitOfWorkMock.Object); leagueService.AddNewLeague(leagueMock.Object); unitOfWorkMock.Verify(x => x.Commit(), Times.Once); }
public void CallRepositoryMethodOnce_WhenDataIsValid() { // Arrange var leagueMock = new Mock <League>(); var repositoryMock = new Mock <IWhoScoredRepository <League> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); ILeagueService leagueService = new LeagueService(repositoryMock.Object, unitOfWorkMock.Object); // Act leagueService.AddNewLeague(leagueMock.Object); // Assert repositoryMock.Verify(x => x.Add(It.IsAny <League>()), Times.Once); }