예제 #1
0
        public void OnlineActivationCommand_CurrentActivationIsValid_LicenseCheckerActivationIsValid_ShareLicenseForAllUsersDisabled__SaveLicenseAndInformUser()
        {
            _expectedLicenseKey = "not empty";
            _interactionInvoker.When(x => x.Invoke(Arg.Any <InputInteraction>())).Do(
                x =>
            {
                ((InputInteraction)x[0]).Success   = true;
                ((InputInteraction)x[0]).InputText = _expectedLicenseKey;
            });

            _activationFromServer = BuildValidActivation(_expectedLicenseKey);

            var viewModel = BuildViewModel();

            viewModel.ShareLicenseForAllUsersEnabled = false; //Important for this test!!!!

            MessageInteraction messageInteraction = null;

            _interactionInvoker.When(x => x.Invoke(Arg.Any <MessageInteraction>())).Do(
                x => messageInteraction = x[0] as MessageInteraction);
            viewModel.OnlineActivationCommand.Execute(null);

            viewModel.LicenseCheckFinishedEvent.WaitOne(_timeout);

            _licenseChecker.Received().SaveActivation(_activationFromServer);
            _interactionInvoker.Received().Invoke(Arg.Any <MessageInteraction>());
            _interactionInvoker.DidNotReceive().Invoke(Arg.Any <StoreLicenseForAllUsersInteraction>());
            Assert.AreEqual(_translation.ActivationSuccessful, messageInteraction.Title);
            Assert.AreEqual(_translation.ActivationSuccessfulMessage, messageInteraction.Text);
            Assert.AreEqual(MessageOptions.OK, messageInteraction.Buttons);
            Assert.AreEqual(MessageIcon.PDFForge, messageInteraction.Icon);
        }
        public void HandleFileList_FewFiles_DoesNotTriggersMessageInteraction()
        {
            _fileWrap.Exists(Arg.Any <string>()).Returns(true);

            _fileConversionHandler.HandleFileList(_droppedFiles);

            _interactionInvoker.DidNotReceive().Invoke(Arg.Any <MessageInteraction>());
            _printFileHelper.Received(1).AddFiles(Arg.Is <IEnumerable <string> >(list => list.Count() == _droppedFiles.Count));
        }
        public void CheckWithErrorResultInOverlay_InvalidProfile_ReturnFalse_NotifyUserInOverlay()
        {
            var faultyResult = new ActionResult(ErrorCode.Ftp_NoAccount); //Random error code, to make the profile invalid

            _profileChecker.CheckJob(_job).Returns(faultyResult);

            var result = _interactiveProfileChecker.CheckWithErrorResultInOverlay(_job);

            Assert.IsFalse(result, "Return value");
            var interaction = _interactionRequest.AssertWasRaised <MessageInteraction>();

            ValidateMessageInteraction(interaction, faultyResult);
            _interactionInvoker.DidNotReceive().Invoke(Arg.Any <MessageInteraction>()); //InteractionInvoker must not be called!
        }
        public void Failure_WithShowMessageFalse_ShowsMessageInteraction()
        {
            var expectedResult = (int)ExitCode.GhostScriptNotFound;
            var message        = "some message";

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

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

            var checker = BuildCheckAllStartupConditions(failingCondition);

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

            Assert.AreEqual(expectedResult, ex.ExitCode);

            _interactionInvoker.DidNotReceive().Invoke(Arg.Any <MessageInteraction>());
        }