public SampleTranscodingListViewModel() : base(new MockTranscodingListView(), null)
        {
            var musicFiles = new[] 
            {
                new SampleMusicFile(new MusicMetadata(new TimeSpan(0, 3, 45), 320000)
                {
                    Artists = new[] { @"Culture Beat" },
                    Title = @"Serenity (Epilog)",
                }, @"C:\Users\Public\Music\Dancefloor\Culture Beat - Serenity.waf"),
                new SampleMusicFile(new MusicMetadata(new TimeSpan(0, 2, 2), 320000)
                {
                    Artists = new[] { "First artist", "Second artist" },
                    Title = "This track has a very long title. Let's see how the UI handles this.",
                }, @"C:\Users\Public\Music\test.m4a"),
                new SampleMusicFile(new MusicMetadata(new TimeSpan(1, 33, 0), 320000)
                {
                    Artists = new string[0],
                    Title = "",
                }, @"C:\Users\Public\Music\Dancefloor\Culture Beat - Serenity.mp4"),
            };
            var transcodingManager = new TranscodingManager();
            musicFiles.Select(x => new TranscodeItem(x, x.FileName + ".mp3")).ToList().ForEach(transcodingManager.AddTranscodeItem);
            transcodingManager.TranscodeItems[0].Progress = 1;
            transcodingManager.TranscodeItems[1].Progress = 0.27;
            transcodingManager.TranscodeItems[2].Error = new InvalidOperationException("Test");
            TranscodingManager = transcodingManager;

            SelectedTranscodeItems.Add(transcodingManager.TranscodeItems.Last());
        }
 public TranscodingController(IMessageService messageService, IShellService shellService, IMusicFileContext musicFileContext, ISelectionService selectionService, 
     TranscodingService transcodingService, Lazy<ITranscoder> transcoder, Lazy<TranscodingListViewModel> transcodingListViewModel)
 {
     this.messageService = messageService;
     this.shellService = shellService;
     this.musicFileContext = musicFileContext;
     this.selectionService = selectionService;
     this.transcodingService = transcodingService;
     this.transcoder = transcoder;
     this.transcodingListViewModel = transcodingListViewModel;
     this.cancellationTokenSources = new Dictionary<TranscodeItem, CancellationTokenSource>();
     this.convertToMp3AllCommand = new DelegateCommand(ConvertToMp3All, CanConvertToMp3All);
     this.convertToMp3SelectedCommand = new DelegateCommand(ConvertToMp3Selected, CanConvertToMp3Selected);
     this.cancelAllCommand = new DelegateCommand(CancelAll, CanCancelAll);
     this.cancelSelectedCommand = new DelegateCommand(CancelSelected, CanCancelSelected);
     this.throttler = new SemaphoreSlim(Environment.ProcessorCount);  // Do not dispose the throttler; it is used after Shutdown to cancel the open tasks
     this.transcodingManager = new TranscodingManager();
 }
        public void AddRemoveTranscodeItemsTest()
        {
            var musicFile1 = new MockMusicFile(new MusicMetadata(TimeSpan.FromSeconds(33), 320), "TestFile1.wma");
            var musicFile2 = new MockMusicFile(new MusicMetadata(TimeSpan.FromSeconds(33), 320), "TestFile2.wma");
            var item1 = new TranscodeItem(musicFile1, "TestFile1.mp3");
            var item2 = new TranscodeItem(musicFile1, "TestFile2.mp3");

            var manager = new TranscodingManager();
            Assert.IsFalse(manager.TranscodeItems.Any());

            manager.AddTranscodeItem(item1);
            manager.AddTranscodeItem(item2);

            Assert.IsTrue(new[] { item1, item2 }.SequenceEqual(manager.TranscodeItems));

            manager.RemoveTranscodeItem(item1);

            Assert.AreEqual(item2, manager.TranscodeItems.Single());
        }