public void ThrowException_WhenPassedVisitIsNull() { // Arrange var efRepositoryMock = new Mock <IEfRepository <Visit> >(); var commitMock = new Mock <ISaveContext>(); var visitsService = new VisitsService(efRepositoryMock.Object, commitMock.Object); efRepositoryMock.Setup(r => r.Update(It.IsAny <Visit>())); // Act & Assert Assert.ThrowsException <ArgumentNullException>(() => visitsService.Update(null)); }
public void CallRepositoryUpdateAndCommitOnce_WhenPassedVisitIsNotNull() { // Arrange var efRepositoryMock = new Mock <IEfRepository <Visit> >(); var commitMock = new Mock <ISaveContext>(); var visitsService = new VisitsService(efRepositoryMock.Object, commitMock.Object); var visit = new Visit(); efRepositoryMock.Setup(r => r.Update(visit)); commitMock.Setup(c => c.Commit()); // Act visitsService.Update(visit); // Assert efRepositoryMock.Verify(r => r.Update(visit), Times.Once); commitMock.Verify(c => c.Commit(), Times.Once); }