Exemple #1
0
        public void BrowseFolderCommand_WhenExecuted_OpensWithCurrentFilename()
        {
            var vm = BuildViewModel();

            vm.SetJob(BuildJob(_pdfProfile));

            _saveFileQuery
            .GetFileName(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <OutputFormat>())
            .Returns(new QueryResult <OutputFilenameResult>(false, new OutputFilenameResult("", OutputFormat.Pdf)));

            vm.BrowseFileCommand.Execute(null);

            _saveFileQuery.Received().GetFileName(vm.OutputFolder, vm.OutputFilename, vm.OutputFormat);
        }
        public void ShowSaveFileDialog_SetValuesFromUserInput_SetFilepathAndOutputFormatInJob()
        {
            var skipPrintDialogCommand = BuildCommand();
            var job = BuildJob(_pdfProfile);

            skipPrintDialogCommand.Execute(job);

            var result = _saveFileQuery
                         .GetFileName(PathSafe.GetDirectoryName(job.OutputFileTemplate),
                                      PathSafe.GetFileName(job.OutputFileTemplate), job.Profile.OutputFormat);

            Assert.AreEqual(result.Data.Filepath, job.OutputFileTemplate);
            Assert.AreEqual(result.Data.OutputFormat, job.Profile.OutputFormat);
        }
Exemple #3
0
        private void MockSaveFileDialog(bool success)
        {
            _saveFileQuery = Substitute.For <IFileNameQuery>();
            var outputFilenameResult            = new OutputFilenameResult(_filepathFromSaveDialog, OutputFormat.Pdf);
            var queryResultOutputFilenameResult = new QueryResult <OutputFilenameResult>(success, outputFilenameResult);

            _saveFileQuery.GetFileName(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <OutputFormat>())
            .Returns(queryResultOutputFilenameResult);
        }
Exemple #4
0
        private void BrowseFileExecute(object parameter)
        {
            var result = _saveFileQuery.GetFileName(OutputFolder, OutputFilename, OutputFormat);

            if (result.Success)
            {
                SetOutputFilenameAndFolder(result.Data.Filepath);
                _latestDialogFilePath = result.Data.Filepath;
                OutputFormat          = result.Data.OutputFormat;
            }
        }
Exemple #5
0
        private void QueryName(Job job)
        {
            var result = _fileNameQuery.GetFileName(job);

            if (result.Success)
            {
                job.OutputFilenameTemplate = result.Data;
            }
            else
            {
                throw new AbortWorkflowException("Cancelled the save dialog.");
            }
        }
        public void Execute(object parameter)
        {
            var job = parameter as Job;

            var folder   = _pathSafe.GetDirectoryName(job.OutputFilenameTemplate) ?? "";
            var filename = _pathSafe.GetFileName(job.OutputFilenameTemplate) ?? "";

            var result = _saveFileQuery.GetFileName(folder, filename, job.Profile.OutputFormat);

            if (result.Success)
            {
                job.OutputFilenameTemplate = result.Data.Filepath;
                job.Profile.OutputFormat   = result.Data.OutputFormat;
            }
        }
 private async Task <QueryResult <OutputFilenameResult> > GetFileOrRetry(string dir, string file, OutputFormat format)
 {
     while (true)
     {
         try
         {
             return(_fileNameQuery.GetFileName(dir, file, format));
         }
         catch (PathTooLongException)
         {
             _translation = _translationFactory.UpdateOrCreateTranslation(_translation);
             var interaction = new MessageInteraction(_translation.PathTooLongText, _translation.PathTooLongTitle, MessageOptions.OK, MessageIcon.Exclamation);
             await _interactionRequest.RaiseAsync(interaction);
         }
     }
 }
 private async Task <QueryResult <OutputFilenameResult> > GetFileOrRetry()
 {
     // Retry while there is a PathTooLongException
     while (true)
     {
         try
         {
             return(_saveFileQuery.GetFileName(OutputFolder, OutputFilename, OutputFormat));
         }
         catch (PathTooLongException)
         {
             var interaction = new MessageInteraction(Translation.PathTooLongText, Translation.PathTooLongTitle, MessageOptions.OK, MessageIcon.Exclamation);
             await _interactionRequest.RaiseAsync(interaction);
         }
     }
 }
        public void Setup()
        {
            _pdfProfile = new ConversionProfile
            {
                Name             = "PDF Profile",
                OutputFormat     = OutputFormat.Pdf,
                FileNameTemplate = "X:\\test.pdf"
            };

            _saveFileQuery = Substitute.For <IFileNameQuery>();

            var outputFilenameResult            = new OutputFilenameResult(_filepathFromSaveDialog, OutputFormat.Jpeg);
            var queryResultOutputFilenameResult = new QueryResult <OutputFilenameResult>(true, outputFilenameResult);

            _saveFileQuery.GetFileName(Arg.Any <string>(), Arg.Any <string>(), Arg.Any <OutputFormat>())
            .Returns(queryResultOutputFilenameResult);
        }
Exemple #10
0
        public void Execute(object parameter)
        {
            var job = parameter as Job;

            var folder = _pathSafe.GetDirectoryName(job.OutputFilenameTemplate) ?? "";

            var filename = _pathSafe.GetFileName(job.OutputFilenameTemplate) ?? "";

            var result = _saveFileQuery.GetFileName(folder, filename, job.Profile.OutputFormat);

            if (!result.Success)
            {
                throw new AbortWorkflowException("User cancelled in SaveFileDialog");
            }

            job.OutputFilenameTemplate = result.Data.Filepath;
            job.Profile.OutputFormat   = result.Data.OutputFormat;
        }