public void CallOnce_EfDbContextSave_When_Photocourse_IsNotNull() { // Arange var mockedModelDbFactory = new Mock <IModelDbFactory>(); var mockedSanitizer = new Mock <ISanitizer>(); var mockedMapper = new Mock <IAutoMapperService>(); var mockedEfDbContext = new Mock <IEfDbContextSaveChanges>(); var mockedIEfDbRepository = new Mock <IPhotoArtSystemEfDbRepository <Photocourse> >(); var service = new PhotocourseService( mockedModelDbFactory.Object, mockedSanitizer.Object, mockedMapper.Object, mockedEfDbContext.Object, mockedIEfDbRepository.Object); // Act service.Update(new PhotocourseTransitional()); // Assert mockedEfDbContext.Verify(x => x.Save(), Times.Once); }
public void Throw_ArgumentNullException_WithProperMessage_When_Photocourse_IsNull() { // Arange var mockedModelDbFactory = new Mock <IModelDbFactory>(); var mockedSanitizer = new Mock <ISanitizer>(); var mockedMapper = new Mock <IAutoMapperService>(); var mockedEfDbContext = new Mock <IEfDbContextSaveChanges>(); var mockedIEfDbRepository = new Mock <IPhotoArtSystemEfDbRepository <Photocourse> >(); var service = new PhotocourseService( mockedModelDbFactory.Object, mockedSanitizer.Object, mockedMapper.Object, mockedEfDbContext.Object, mockedIEfDbRepository.Object); // Act & Assert Assert.That( () => service.Update(null), Throws.ArgumentNullException.With.Message.Contains( GlobalConstants.PhotocourseTransitionalRequiredExceptionMessage)); }