public void OnlineActivationCommand_CurrentEditionIsNotValid_LicenseCheckerActivationIsValid_SaveNewActivationAndUpdateEditionAndStoreLicenseForAllUsersQuery()
        {
            _expectedLicenseKey = "not empty";
            _interactionInvoker.When(x => x.Invoke(Arg.Any <InputInteraction>())).Do(
                x =>
            {
                var inputInteraction       = x.Arg <InputInteraction>();
                inputInteraction.Success   = true;
                inputInteraction.InputText = _expectedLicenseKey;
            });
            _activationHelper
            .When(x => x.ActivateWithoutSavingActivation(_expectedLicenseKey))
            .Do(x =>
            {
                _activationHelper.IsLicenseValid.Returns(true);
            });

            var viewModel             = BuildViewModel();
            var propertyChangedEvents = new List <string>();

            viewModel.PropertyChanged += (sender, args) => propertyChangedEvents.Add(args.PropertyName);

            viewModel.OnlineActivationCommand.Execute(null);

            viewModel.LicenseCheckFinishedEvent.WaitOne(_timeout);

            _interactionInvoker.Received().Invoke(Arg.Any <StoreLicenseForAllUsersInteraction>());
        }
Example #2
0
        public void RetypeFileName_NotifiesUser()
        {
            var translation = new InteractiveWorkflowTranslation();

            HandleMessageInteraction(interaction => interaction.Response = MessageResponse.OK);
            HandleSaveFileInteraction(interaction => interaction.Success = false);
            var query = BuildFileNameQuery();

            query.RetypeFileName(_someFile, OutputFormat.Pdf);

            _interactionInvoker.Received().Invoke(Arg.Is <MessageInteraction>(i => i.Text.Contains(translation.RetypeFilenameMessage)));
            _interactionInvoker.Received().Invoke(Arg.Any <SaveFileInteraction>());
        }
Example #3
0
        public void RetypeFileName_RetypeReasonIsCopyError_NotifiesUserWithCopyErrorMessage()
        {
            HandleMessageInteraction(interaction => interaction.Response = MessageResponse.OK);
            HandleSaveFileInteraction(interaction => interaction.Success = false);

            var query = BuildFileNameQuery();

            query.RetypeFileNameQuery(_someFile, OutputFormat.Pdf, RetypeReason.CopyError);

            _interactionInvoker.Received().Invoke(Arg.Is <MessageInteraction>(i => i.Title.Equals("PDFCreator")));
            _interactionInvoker.Received().Invoke(Arg.Is <MessageInteraction>(i => i.Text.Contains(_someFile)));
            _interactionInvoker.Received().Invoke(Arg.Is <MessageInteraction>(i => i.Text.Equals(_translation.FormatCopyErrorMessage(_someFile))));
            _interactionInvoker.Received().Invoke(Arg.Is <MessageInteraction>(i => i.Buttons == MessageOptions.OK));
            _interactionInvoker.Received().Invoke(Arg.Is <MessageInteraction>(i => i.Icon == MessageIcon.Warning));
        }
Example #4
0
        public void WhenSuccessful_ShowsSuccessMessage()
        {
            var assistant = BuildAssistant();

            assistant.SendTestMail(_profile, new Accounts());

            _interactionInvoker.Received().Invoke(Arg.Any <MessageInteraction>());

            var messageInteraction =
                _interactions.Where(x => x is MessageInteraction).Cast <MessageInteraction>().First();

            Assert.AreEqual("SmtpEmailActionSettings\\SendTestMail", messageInteraction.Title);
            Assert.AreEqual("SmtpEmailActionSettings\\TestMailSent", messageInteraction.Text);
            Assert.AreEqual(MessageIcon.Info, messageInteraction.Icon);
        }
        public void ConvertFileCommand_WhenFileWasSelected_ConvertsFile()
        {
            var selectedFile = @"Some\Path\To\File.txt";

            _interactionInvoker.When(i => i.Invoke(Arg.Any <OpenFileInteraction>())).Do(ci =>
            {
                var interaction      = ci.Arg <OpenFileInteraction>();
                interaction.Success  = true;
                interaction.FileName = selectedFile;
            });

            HomeViewModel.ConvertFileCommand.Execute(null);

            _interactionInvoker.Received(1).Invoke(Arg.Any <OpenFileInteraction>());
            _fileConversionHandler.Received(1).HandleFileList(Arg.Is <List <string> >(l => l.Single().Equals(selectedFile)));
        }
Example #6
0
        public void WhenSuccessful_ShowsSuccessMessage()
        {
            var translation = new SmtpSettingsAndActionControlTranslation();
            var assistant   = BuildAssistant();

            assistant.SendTestMail(_profile, new Accounts());

            _interactionInvoker.Received().Invoke(Arg.Any <MessageInteraction>());

            var messageInteraction =
                _interactions.Where(x => x is MessageInteraction).Cast <MessageInteraction>().First();

            Assert.AreEqual(translation.SendTestMail, messageInteraction.Title);
            Assert.AreEqual(translation.GetTestMailSentFormattedTranslation(string.Empty), messageInteraction.Text);
            Assert.AreEqual(MessageIcon.Info, messageInteraction.Icon);
        }
        public void OnlineActivationCommand_CurrentActivationIsNotValid_LicenseCheckerActivationIsValid_SaveNewActivationAndStoreLicenseForAllUsersQuery()
        {
            _expectedLicenseKey = "not empty";
            _interactionInvoker.When(x => x.Invoke(Arg.Any <InputInteraction>())).Do(
                x =>
            {
                var inputInteraction       = x.Arg <InputInteraction>();
                inputInteraction.Success   = true;
                inputInteraction.InputText = _expectedLicenseKey;
            });
            _licenseChecker.ActivateWithoutSaving(_expectedLicenseKey).Returns(x => BuildValidActivation(_expectedLicenseKey).Some <Activation, LicenseError>());

            var viewModel = BuildViewModel();

            viewModel.OnlineActivationCommand.Execute(null);
            viewModel.LicenseCheckFinishedEvent.WaitOne(_timeout);

            _interactionInvoker.Received().Invoke(Arg.Any <StoreLicenseForAllUsersInteraction>());
        }
Example #8
0
        public void WhenOnTerminalServer_ShowsMoreInfoInteraction()
        {
            var terminalServerCondition = BuildTerminalServerCondition();

            _terminalServerDetection.IsTerminalServer().Returns(true);

            terminalServerCondition.Check();

            _interactionInvoker.Received().Invoke(Arg.Any <MessageInteraction>());
            var interaction = (MessageInteraction)_interactionInvoker.ReceivedCalls().First().GetArguments()[0];

            Assert.AreEqual("Program\\UsePDFCreatorTerminalServer", interaction.Text);
            Assert.AreEqual(MessageOptions.MoreInfoCancel, interaction.Buttons);
        }
Example #9
0
        public void LoadIniSettings_WithInvalidSettings_DisplayWarningAndDoesNotApplySettings()
        {
            const string filename = "MyFileName";

            SetSuccessfulOpenFileInteraction(filename);

            _invoker.When(x => x.Invoke(Arg.Any <MessageInteraction>())).Do(info => { info.Arg <MessageInteraction>().Response = MessageResponse.Yes; });
            _settingsHelper.CheckValidSettings(Arg.Any <PdfCreatorSettings>()).Returns(false);

            _iniSettingsAssistant.LoadIniSettings();

            _invoker.Received(2).Invoke(Arg.Any <MessageInteraction>());

            _settingsManager.DidNotReceive().ApplyAndSaveSettings(Arg.Any <PdfCreatorSettings>());
        }
Example #10
0
        public void SetupDefaultViewerNotFoundError_RunExecute_TryToShowMessage()
        {
            var command = BuildCommand();

            var defaultViewerByOutputFormat = _settingsProvider.Settings.GetDefaultViewerByOutputFormat(OutputFormat.Pdf);

            defaultViewerByOutputFormat.IsActive = true;

            var actionResult = new ActionResult();

            actionResult.Add(ErrorCode.DefaultViewer_Not_Found);
            _defaultViewerAction.OpenOutputFile(_fileList.First()).Returns(actionResult);
            command.Execute(_fileList.First());
            _interactionInvoker.Received(1).Invoke(Arg.Any <MessageInteraction>());
        }
Example #11
0
        public void WithInvalidLicense_UserWantsToRenew_LicenseInteractionIsTriggered()
        {
            _interactionInvoker
            .When(x => x.Invoke(Arg.Any <MessageInteraction>()))
            .Do(x =>
            {
                var tmpInteraction      = x.Arg <MessageInteraction>();
                tmpInteraction.Response = MessageResponse.Yes;
            });

            var licenseCondition = BuildCheckLicenseConditions();

            licenseCondition.Check();
            _interactionInvoker.Received().Invoke(Arg.Any <LicenseInteraction>());
        }
        public void FailureWithMessage_ShowsMessageInteraction()
        {
            var expectedResult = (int)ExitCode.GhostScriptNotFound;
            var message        = "some message";

            var failingCondition = Substitute.For <IStartupCondition>();

            failingCondition.Check().Returns(StartupConditionResult.BuildErrorWithMessage(expectedResult, message));

            var checker = BuildCheckAllStartupConditions(failingCondition);

            var ex = Assert.Throws <StartupConditionFailedException>(() => checker.CheckAll());

            Assert.AreEqual(expectedResult, ex.ExitCode);

            _interactionInvoker.Received().Invoke(Arg.Is <MessageInteraction>(i => i.Text == message));
        }
Example #13
0
        public void WithInvalidLicense_UserWantsToRenew_LicenseInteractionIsTriggeredWithKey()
        {
            _activationHelper.LicenseStatus.Returns(LicenseStatus.Error);
            _activationHelper.Activation.Key = "AAA-BBB";

            _interactionInvoker
            .When(x => x.Invoke(Arg.Any <MessageInteraction>()))
            .Do(x =>
            {
                var tmpInteraction      = x.Arg <MessageInteraction>();
                tmpInteraction.Response = MessageResponse.Yes;
            });

            var licenseCondition = BuildCheckLicenseConditions();

            licenseCondition.Check();

            _interactionInvoker.Received().Invoke(Arg.Any <LicenseInteraction>());
        }
        public void HandleFileList_ManyFiles_TriggersMessageInteraction()
        {
            _droppedFiles.Clear();

            _interactionInvoker.Invoke(Arg.Do <MessageInteraction>(i =>
            {
                i.Response      = MessageResponse.Yes;
                var translation = new FileConversionAssistantTranslation();
                Assert.AreEqual(translation.GetFormattedMoreThanXFilesQuestion(_droppedFiles.Count), i.Text);
            }
                                                                   ));

            for (int i = 0; i <= 100; i++)
            {
                _droppedFiles.Add("file" + i);
            }

            _fileWrap.Exists(Arg.Any <string>()).Returns(true);

            _fileConversionHandler.HandleFileList(_droppedFiles);

            _interactionInvoker.Received(1).Invoke(Arg.Any <MessageInteraction>());
            _printFileHelper.Received(1).AddFiles(Arg.Is <IEnumerable <string> >(list => list.Count() == _droppedFiles.Count));
        }
Example #15
0
        public void AddAccount_InteractionInvokerInvokesInteraction()
        {
            _dropboxAccountAddCommand.Execute(null);

            _interactionInvoker.Received().Invoke(Arg.Any <DropboxAccountInteraction>());
        }