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>());
        }
Exemple #2
0
        public void AfterRenewingLicense_LicenseIsInvalid_Success()
        {
            // When asked to renew the activation, we'll answer 'Yes"
            _interactionInvoker
            .When(x => x.Invoke(Arg.Any <MessageInteraction>()))
            .Do(x =>
            {
                var messageInteraction = x.Arg <MessageInteraction>();
                if (messageInteraction.Buttons == MessageOptions.YesNo)
                {
                    messageInteraction.Response = MessageResponse.Yes;
                }
            });

            _activationHelper.LicenseStatus.Returns(LicenseStatus.Error);
            _activationHelper.Activation.Key = "AAA-BBB";
            _activationHelper
            .When(x => x.LoadActivation())
            .Do(x =>
            {
                bool wasRenewed =
                    _interactionInvoker.ReceivedCalls()
                    .Any(c => c.GetArguments()[0].GetType() == typeof(LicenseInteraction));
                // License becomes valid after it was renewed
                _activationHelper.LicenseStatus.Returns(wasRenewed ? LicenseStatus.Valid : LicenseStatus.Error);
                _activationHelper.IsLicenseValid.Returns(wasRenewed);
            });

            var licenseCondition = BuildCheckLicenseConditions();

            var result = licenseCondition.Check();

            Assert.IsTrue(result.IsSuccessful);
        }