private ApplicationSettingsViewModel BuildViewModel()
        {
            // TODO extend tests based on Edition
            var licenseChecker   = Substitute.For <ILicenseChecker>();
            var offlineActivator = Substitute.For <IOfflineActivator>();

            var printerHelper = Substitute.For <IPrinterHelper>();

            printerHelper.GetApplicablePDFCreatorPrinter(Arg.Any <string>(), Arg.Any <string>()).Returns("PDFCreator");
            var settingsHelper  = Substitute.For <ISettingsProvider>();
            var settingsManager = Substitute.For <ISettingsManager>();

            settingsManager.GetSettingsProvider().Returns(settingsHelper);
            var updateAssistant = Substitute.For <IUpdateAssistant>();
            var uacAssistant    = Substitute.For <IUacAssistant>();
            var process         = Substitute.For <IProcessStarter>();

            var generalTabViewModel = new GeneralTabViewModel(Substitute.For <ILanguageProvider>(), null, updateAssistant, uacAssistant, Substitute.For <IInteractionInvoker>(),
                                                              Substitute.For <IOsHelper>(), Substitute.For <IProcessStarter>(), new GeneralTabTranslation());
            var printerTabViewModel = new PrinterTabViewModel(printerHelper, null, null, null, printerHelper, new PrinterTabTranslation());
            var titleTabViewModel   = new TitleTabViewModel(new TitleTabTranslation(), new TranslationFactory());

            var debugTabViewModel        = new DebugTabViewModel(settingsManager, Substitute.For <ITestPageHelper>(), Substitute.For <IFile>(), Substitute.For <IProcessStarter>(), Substitute.For <IInteractionInvoker>(), printerHelper, Substitute.For <IIniSettingsAssistant>(), new DebugTabTranslation());
            var licenseTabViewModel      = new LicenseTabViewModel(process, licenseChecker, offlineActivator, null, Substitute.For <IDispatcher>(), new LicenseTabTranslation());
            var pdfArchitectTabViewModel = new PdfArchitectTabViewModel(Substitute.For <IPdfArchitectCheck>(), Substitute.For <IProcessStarter>(), new PdfArchitectTabTranslation());

            var viewModelBundle = new ApplicationSettingsViewModelBundle(generalTabViewModel, printerTabViewModel, titleTabViewModel, debugTabViewModel, licenseTabViewModel, pdfArchitectTabViewModel);

            return(new ApplicationSettingsViewModel(viewModelBundle, new TranslationHelper(new DefaultSettingsProvider(), new AssemblyHelper(), new TranslationFactory()), new LicenseOptionProvider(false), new ApplicationSettingsWindowTranslation()));
        }
 public ApplicationSettingsViewModelBundle(GeneralTabViewModel generalTabViewModel,
                                           PrinterTabViewModel printerTabViewModel, TitleTabViewModel titleTabViewModel,
                                           DebugTabViewModel debugTabViewModel, LicenseTabViewModel licenseTabViewModel, PdfArchitectTabViewModel pdfArchitectTabViewModel)
 {
     GeneralTabViewModel      = generalTabViewModel;
     PrinterTabViewModel      = printerTabViewModel;
     TitleTabViewModel        = titleTabViewModel;
     DebugTabViewModel        = debugTabViewModel;
     LicenseTabViewModel      = licenseTabViewModel;
     PdfArchitectTabViewModel = pdfArchitectTabViewModel;
 }
        public void TitleReplacementAdd_WithEmptyList_CanExecute()
        {
            var settings = new Conversion.Settings.ApplicationSettings();

            settings.TitleReplacement = new TitleReplacement[] {};

            var titleTabViewModel = new TitleTabViewModel(_translator);

            titleTabViewModel.ApplyTitleReplacements(settings.TitleReplacement);

            Assert.IsTrue(titleTabViewModel.TitleAddCommand.CanExecute(null));
        }
        public void TitleReplacementDelete_WithNonEmptyList_CanExecute()
        {
            var settings = new Conversion.Settings.ApplicationSettings();

            settings.TitleReplacement = new[] { new TitleReplacement(ReplacementType.Replace, "a", "b"), new TitleReplacement(ReplacementType.Replace, "c", "d") }.ToList();

            var titleTabViewModel = new TitleTabViewModel(_translator);

            titleTabViewModel.ApplyTitleReplacements(settings.TitleReplacement);

            Assert.IsTrue(titleTabViewModel.TitleDeleteCommand.CanExecute(null));
        }
Ejemplo n.º 5
0
        public void TitleReplacementDelete_WithEmptyList_CannotExecute()
        {
            var settings = new ApplicationSettings();

            settings.TitleReplacement = new TitleReplacement[] { };

            var titleTabViewModel = new TitleTabViewModel(_translator);

            titleTabViewModel.ApplyTitleReplacements(settings.TitleReplacement);

            Assert.IsFalse(titleTabViewModel.TitleDeleteCommand.CanExecute(null));
        }
        public void TitleReplacementAdd_WithEmptyList_InsertsOneElement()
        {
            var settings = new Conversion.Settings.ApplicationSettings();

            settings.TitleReplacement = new TitleReplacement[] {}.ToList();

            var titleTabViewModel = new TitleTabViewModel(_translator);

            titleTabViewModel.ApplyTitleReplacements(settings.TitleReplacement);

            titleTabViewModel.TitleAddCommand.Execute(null);

            Assert.AreEqual(1, settings.TitleReplacement.Count);
        }
        public void TitleReplacementAdd_WithNonEmptyList_NewElementIsCurrent()
        {
            var settings = new Conversion.Settings.ApplicationSettings();

            settings.TitleReplacement = new[] { new TitleReplacement(ReplacementType.Replace, "a", "b"), new TitleReplacement(ReplacementType.Replace, "c", "d") }.ToList();

            var titleTabViewModel = new TitleTabViewModel(_translator);

            titleTabViewModel.ApplyTitleReplacements(settings.TitleReplacement);
            var cv = CollectionViewSource.GetDefaultView(titleTabViewModel.TitleReplacements);

            titleTabViewModel.TitleAddCommand.Execute(null);

            Assert.AreEqual(2, cv.CurrentPosition);
        }
        public void TitleReplacementDelete_AfterExecute_OtherElementStillThere()
        {
            var settings = new Conversion.Settings.ApplicationSettings();

            settings.TitleReplacement = new[] { new TitleReplacement(ReplacementType.Replace, "a", "b"), new TitleReplacement(ReplacementType.Replace, "c", "d") }.ToList();

            var titleTabViewModel = new TitleTabViewModel(_translator);

            titleTabViewModel.ApplyTitleReplacements(settings.TitleReplacement);

            var otherElement = settings.TitleReplacement[1];

            titleTabViewModel.TitleDeleteCommand.Execute(null);

            Assert.IsTrue(titleTabViewModel.TitleReplacements.Contains(otherElement));
        }
        public void TitleReplacementDelete_AfterExecute_ElementIsRemoved()
        {
            var settings = new Conversion.Settings.ApplicationSettings();

            settings.TitleReplacement = new[] { new TitleReplacement(ReplacementType.Replace, "a", "b"), new TitleReplacement(ReplacementType.Replace, "c", "d") }.ToList();

            var titleTabViewModel = new TitleTabViewModel(_translator);

            titleTabViewModel.ApplyTitleReplacements(settings.TitleReplacement);

            var deletedElement = settings.TitleReplacement[0];

            titleTabViewModel.TitleDeleteCommand.Execute(null);

            Assert.IsFalse(titleTabViewModel.TitleReplacements.Contains(deletedElement));
        }
        public void TitleReplacementDelete_CurrentItemChanged_RaisesCommandCanExecuteChanged()
        {
            var wasRaised = false;
            var settings  = new Conversion.Settings.ApplicationSettings();

            settings.TitleReplacement = new[] { new TitleReplacement(ReplacementType.Replace, "a", "b"), new TitleReplacement(ReplacementType.Replace, "c", "d") }.ToList();

            var titleTabViewModel = new TitleTabViewModel(_translator);

            titleTabViewModel.ApplyTitleReplacements(settings.TitleReplacement);

            titleTabViewModel.TitleDeleteCommand.CanExecuteChanged += (sender, args) => wasRaised = true;

            var cv = CollectionViewSource.GetDefaultView(titleTabViewModel.TitleReplacements);

            cv.MoveCurrentToPrevious();

            Assert.IsTrue(wasRaised);
        }
        public void TitleReplacementDelete_WithNullList_CannotExecute()
        {
            var titleTabViewModel = new TitleTabViewModel(_translator);

            Assert.IsFalse(titleTabViewModel.TitleDeleteCommand.CanExecute(null));
        }