Exemplo n.º 1
0
        public void EnterLicenseKeyCommand_CurrentEditionIsNotValid_LicenseCheckerActivationIsNotValid_UpdateEditionWithGivenKeyDoNotSaveNewEdition()
        {
            _expectedLicenseKey                   = "given-key";
            _licenseCheckerActivation             = CreateValidActivation();
            _editionFactory                       = BuildValidEditionHelper();
            _editionFactory.Edition.LicenseStatus = LicenseStatus.Error;
            var invalidEdition = CreateValidEdition();

            invalidEdition.LicenseStatus = LicenseStatus.Error; //make received Edition invalid
            _editionFactory.DetermineEdition(_licenseCheckerActivation).Returns(invalidEdition);
            _editionFactory.ReloadEdition().Returns(invalidEdition);
            var           viewModel             = BuildViewModel(_editionFactory);
            List <string> propertyChangedEvents = new List <string>();

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

            viewModel.EnterLicenseKeyCommand.Execute(null);

            viewModel.LicenseCheckFinishedEvent.WaitOne(_timeout);
            _editionFactory.DidNotReceive().ReloadEdition();
            _licenseChecker.DidNotReceive().SaveActivation(null);
            Assert.Contains(nameof(viewModel.Edition), propertyChangedEvents);
            Assert.AreSame(invalidEdition, viewModel.Edition);
            Assert.AreEqual(_expectedLicenseKey.Replace("-", ""), viewModel.Edition.Activation.Key, "Given key not set in updated license");
        }
Exemplo n.º 2
0
        public void EnterLicenseKeyCommand_CurrentEditionIsValid_LicenseCheckerActivationIsNotValid_DoNotSaveNewActivationAndDoNotUpdateEdition()
        {
            _expectedLicenseKey       = "not empty";
            _licenseCheckerActivation = CreateValidActivation();
            _editionFactory           = BuildValidEditionHelper();
            var invalidEdition = CreateValidEdition();

            invalidEdition.LicenseStatus = LicenseStatus.Error; //make received Edition invalid
            _editionFactory.DetermineEdition(_licenseCheckerActivation).Returns(invalidEdition);
            _editionFactory.ReloadEdition().Returns(invalidEdition);
            var           viewModel             = BuildViewModel(_editionFactory);
            List <string> propertyChangedEvents = new List <string>();

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

            viewModel.EnterLicenseKeyCommand.Execute(null);

            viewModel.LicenseCheckFinishedEvent.WaitOne(_timeout);
            _editionFactory.DidNotReceive().ReloadEdition();
            _licenseChecker.DidNotReceive().SaveActivation(Arg.Any <Activation>());
            Assert.Contains(nameof(viewModel.Edition), propertyChangedEvents);
            Assert.AreSame(_editionFactory.Edition, viewModel.Edition); //Keep old edition
        }