public async Task EncodingCancellationTest2() { TestIFolderSelectorService folderSelector = new TestIFolderSelectorService(); folderSelector.FolderPath = @"C:\folder\"; viewModel.FolderSelectorService = folderSelector; viewModel.Path = @"C:\dir\"; TestIInputDataService inputDataService = new TestIInputDataService(); inputDataService.InputCommand = InputCommand.Decode; viewModel.InputDataService = inputDataService; WritableMemoryStream outputStream = new WritableMemoryStream(); TestIPlatformService platform = new TestIPlatformService(); platform.WriteFileFunc = x => { if (string.Equals(x, @"C:\folder\dir\f2.dat", StringComparison.OrdinalIgnoreCase)) { viewModel.Cancel(); } return(outputStream); }; platform.ReadFileFunc = x => new BufferBuilder() .AddByte(0x2) .AddInt(0x9) .AddByte(0x0) .AddLong(0x1) .AddByte(0x1) .AddInt(0x6) .AddString("dir") .AddInt(2) .AddByte(0x0) .AddInt(0xC) .AddString("f1.dat") .AddLong(200 * 1024 * 8) // 200Kb .AddByte(0x0, 200 * 1024) .AddByte(0x0) .AddInt(0xC) .AddString("f2.dat") .AddLong(300 * 1024 * 8) // 300Kb .AddByte(0x0, 300 * 1024).GetStream(); viewModel.DecodingService = new DefaultHuffmanDecodingService(platform, new DefaultStreamParser()); await viewModel.Run(); Assert.AreEqual(256 * 1024 * 8, outputStream.Length); }
private void SetupDecodingService(Action decodeAction) { TestIFolderSelectorService folderSelector = new TestIFolderSelectorService(); folderSelector.FolderPath = @"C:\folder\"; viewModel.FolderSelectorService = folderSelector; TestIInputDataService inputDataService = new TestIInputDataService(); inputDataService.InputCommand = InputCommand.Decode; viewModel.InputDataService = inputDataService; TestIHuffmanDecodingService encodingService = new TestIHuffmanDecodingService(); encodingService.DecodeAction = decodeAction; viewModel.DecodingService = encodingService; }