Blog.Logic.Core.Tests.MediaLogicTest.ShouldThrowExceptionWhenAddMediaFailsWithConfigurationFetchOnCreatingThumbnail C# (CSharp) Method

ShouldThrowExceptionWhenAddMediaFailsWithConfigurationFetchOnCreatingThumbnail() private method

        public void ShouldThrowExceptionWhenAddMediaFailsWithConfigurationFetchOnCreatingThumbnail()
        {
            var guid = Guid.NewGuid().ToString();

            _mediaRepository = new Mock<IMediaRepository>();

            _albumRepository = new Mock<IAlbumRepository>();
            _albumRepository.Setup(a => a.Find(It.IsAny<Expression<Func<Album, bool>>>(), false))
                .Returns(new List<Album>());
            _albumRepository.Setup(a => a.Add(It.IsAny<Album>()))
                .Returns(new Album { AlbumId = 1, AlbumName = "foo" });

            _imageHelper = new Mock<IImageHelper>();
            _imageHelper.Setup(a => a.GenerateImagePath(It.IsAny<int>(), It.IsAny<string>(),
                It.IsAny<string>())).Returns(_rootPath + @"\AddedImages\1\" + guid);
            
            _configurationHelper = new Mock<IConfigurationHelper>();
            _configurationHelper.Setup(a => a.GetAppSettings(It.IsAny<string>())).Throws(new Exception());

            _fileHelper = new Mock<IFileHelper>();
            _fileHelper.Setup(a => a.MoveFile(It.IsAny<string>(), It.IsAny<string>())).Returns(true);
            _fileHelper.Setup(a => a.CreateDirectory(It.IsAny<string>())).Throws(new Exception());

            _mediaLogic = new MediaLogic(_mediaRepository.Object, _albumRepository.Object,
                _imageHelper.Object, _configurationHelper.Object, _fileHelper.Object);

            Assert.Throws<BlogException>(() => _mediaLogic.Add(new Common.Contracts.User { Id = 1 },
                "foo", "foobarbaz.gif", _rootPath + @"\TestImages\foobarbaz.gif", "image/gif"));
        }
MediaLogicTest