public async Task <IActionResult> Delete(string id) { var customer = await _informationService.Get(id); if (customer == null) { return(NotFound()); } await _informationService.Delete(id); return(NoContent()); }
public void CallOnce_EfDbContextSave_When_Information_IsNotNull() { // Arange var mockedMapper = new Mock <IAutoMapperService>(); var mockedEfDbContext = new Mock <IEfDbContextSaveChanges>(); var mockedIEfDbRepository = new Mock <IPhotoArtSystemEfDbRepository <Information> >(); var service = new InformationService(mockedMapper.Object, mockedEfDbContext.Object, mockedIEfDbRepository.Object); // Act service.Delete(new InformationTransitional()); // Assert mockedEfDbContext.Verify(x => x.Save(), Times.Once); }
public void Throw_ArgumentNullException_WithProperMessage_When_Information_IsNull() { // Arange var mockedMapper = new Mock <IAutoMapperService>(); var mockedEfDbContext = new Mock <IEfDbContextSaveChanges>(); var mockedIEfDbRepository = new Mock <IPhotoArtSystemEfDbRepository <Information> >(); var service = new InformationService(mockedMapper.Object, mockedEfDbContext.Object, mockedIEfDbRepository.Object); // Act & Assert Assert.That( () => service.Delete(null), Throws.ArgumentNullException.With.Message.Contains( GlobalConstants.InformationTransitionalRequiredExceptionMessage)); }