Exemplo n.º 1
0
        private string RemoveExtension(string filePath)
        {
            var pathSafe             = new PathWrapSafe();
            var directory            = pathSafe.GetDirectoryName(filePath);
            var fileWithoutExtension = pathSafe.GetFileNameWithoutExtension(filePath);

            return(Path.Combine(directory, fileWithoutExtension));
        }
Exemplo n.º 2
0
        private GhostscriptDiscovery CreateGhostscriptDiscoveryWithMocks(string appPath = @"C:\Program Files\MyApp", bool x64 = true)
        {
            var pathWrapSafe   = new PathWrapSafe();
            var assemblyHelper = MockRepository.GenerateStub <IAssemblyHelper>();

            assemblyHelper.Stub(x => x.GetCurrentAssemblyDirectory()).Return(appPath);

            var osHelper = MockRepository.GenerateStub <IOsHelper>();

            osHelper.Stub(x => x.Is64BitOperatingSystem).Return(x64);

            return(new GhostscriptDiscovery(_fileMock, _registryMock, assemblyHelper, osHelper));
        }
Exemplo n.º 3
0
        public void UniqueFile_ExistingFilePathWithMaximumPathLength_UniqueFilenameCallsEllpipsisForTooLongPath()
        {
            const string dir245Chars     = @"C:\ThisIsAVeryLongFileNameBecauseItHasMoreThan150CharactersAndToReachThatIHaveToWriteALotMoreTextThanICanThinkAboutRightNowIfYouReadThisUpToHereIOwnYouALittleSnackAndIStillNeedAFewMoreCharactersLetsSimplyCountOneTwoThreeFourFiveSixSevenEightNine";
            const string fileName13Chars = "File12345.pdf";
            var          pathWrapSafe    = new PathWrapSafe();
            //Combine adds a "\" so the result is the max path lengh of 260
            var tooLongPath = pathWrapSafe.Combine(dir245Chars, fileName13Chars);

            _file.Exists("").ReturnsForAnyArgs(x => true, x => false);
            _directory.Exists("").ReturnsForAnyArgs(false);

            var uniqueFilename = new UniqueFilename(tooLongPath, _directory, _file, _pathUtil);

            Assert.Throws <PathTooLongException>(() => uniqueFilename.CreateUniqueFileName());
        }
Exemplo n.º 4
0
        public void ShowSaveFileDialog_SetValuesFromUserInput_SetFilepathAndOutputFormatInJob()
        {
            var pathSafe = new PathWrapSafe();
            var skipPrintDialogCommand = BuildCommand();
            var job = BuildJob(_pdfProfile);

            skipPrintDialogCommand.Execute(job);

            var result = _saveFileQuery
                         .GetFileName(pathSafe.GetDirectoryName(job.OutputFilenameTemplate),
                                      pathSafe.GetFileName(job.OutputFilenameTemplate), job.Profile.OutputFormat);

            Assert.AreEqual(result.Data.Filepath, job.OutputFilenameTemplate);
            Assert.AreEqual(result.Data.OutputFormat, job.Profile.OutputFormat);
        }
Exemplo n.º 5
0
        public void ShowSaveFileDialog_SetValuesFromUserInput_FilepathAndOutputFormatHasChanged()
        {
            var pathSafe = new PathWrapSafe();
            var skipPrintDialogCommand = BuildCommand();
            var job = BuildJob(_pdfProfile);

            var diffFilenameTemplate = job.OutputFilenameTemplate;
            var diffOutputFormat     = job.Profile.OutputFormat;

            skipPrintDialogCommand.Execute(job);

            _saveFileQuery
            .GetFileName(pathSafe.GetDirectoryName(job.OutputFilenameTemplate),
                         pathSafe.GetFileName(job.OutputFilenameTemplate), job.Profile.OutputFormat);

            Assert.AreNotEqual(job.OutputFilenameTemplate, diffFilenameTemplate);
            Assert.AreNotEqual(job.Profile.OutputFormat, diffOutputFormat);
        }