コード例 #1
0
        public async Task <IActionResult> Delete(string id)
        {
            var customer = await _informationService.Get(id);

            if (customer == null)
            {
                return(NotFound());
            }
            await _informationService.Delete(id);

            return(NoContent());
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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));
        }