Ejemplo n.º 1
0
        public void Setup()
        {
            _author = Builder <Author>
                      .CreateNew()
                      .Build();

            _command = new MoveAuthorCommand
            {
                AuthorId        = 1,
                SourcePath      = @"C:\Test\Music\Author".AsOsAgnostic(),
                DestinationPath = @"C:\Test\Music2\Author".AsOsAgnostic()
            };

            _bulkCommand = new BulkMoveAuthorCommand
            {
                Author = new List <BulkMoveAuthor>
                {
                    new BulkMoveAuthor
                    {
                        AuthorId   = 1,
                        SourcePath = @"C:\Test\Music\Author".AsOsAgnostic()
                    }
                },
                DestinationRootFolder = @"C:\Test\Music2".AsOsAgnostic()
            };

            Mocker.GetMock <IAuthorService>()
            .Setup(s => s.GetAuthor(It.IsAny <int>()))
            .Returns(_author);

            Mocker.GetMock <IDiskProvider>()
            .Setup(s => s.FolderExists(It.IsAny <string>()))
            .Returns(true);
        }
Ejemplo n.º 2
0
        public void Execute(BulkMoveAuthorCommand message)
        {
            var authorToMove          = message.Author;
            var destinationRootFolder = message.DestinationRootFolder;

            _logger.ProgressInfo("Moving {0} author to '{1}'", authorToMove.Count, destinationRootFolder);

            for (var index = 0; index < authorToMove.Count; index++)
            {
                var s               = authorToMove[index];
                var author          = _authorService.GetAuthor(s.AuthorId);
                var destinationPath = Path.Combine(destinationRootFolder, _filenameBuilder.GetAuthorFolder(author));

                MoveSingleAuthor(author, s.SourcePath, destinationPath, index, authorToMove.Count);
            }

            _logger.ProgressInfo("Finished moving {0} author to '{1}'", authorToMove.Count, destinationRootFolder);
        }