Exemplo n.º 1
0
        public void OkCommand_CanExecute_OwnerPasswordIsRequiredAndNotSet_IsFalse()
        {
            var viewModel = new EncryptionPasswordViewModel(new EncryptionPasswordsWindowTranslation());

            viewModel.SetInteraction(new EncryptionPasswordInteraction(true, true, false));
            Assert.IsFalse(viewModel.OkCommand.CanExecute(null));
        }
Exemplo n.º 2
0
        public void OkCommand_CanExecute_IfSkipNotShown_IsTrue()
        {
            var viewModel = new EncryptionPasswordViewModel(new EncryptionPasswordsWindowTranslation());

            viewModel.SetInteraction(new EncryptionPasswordInteraction(false, true, true));
            Assert.IsTrue(viewModel.OkCommand.CanExecute(null));
        }
Exemplo n.º 3
0
        public void OkCommand_CanExecute_RequiredPasswordsAreSet_IsTrue()
        {
            var viewModel = new EncryptionPasswordViewModel(new EncryptionPasswordsWindowTranslation());

            viewModel.SetInteraction(new EncryptionPasswordInteraction(true, false, true));
            viewModel.Interaction.UserPassword = "******";
            Assert.True(viewModel.OkCommand.CanExecute(null));
        }
Exemplo n.º 4
0
        public void OnInteractionSet_SetsPasswordsInView()
        {
            var viewModel   = new EncryptionPasswordViewModel(new EncryptionPasswordsWindowTranslation());
            var interaction = new EncryptionPasswordInteraction(false, true, true);

            var actionWasCalled = false;

            viewModel.SetPasswordInUi = (x, y) => actionWasCalled = true;

            viewModel.SetInteraction(interaction);
            Assert.IsTrue(actionWasCalled);
        }
Exemplo n.º 5
0
        public void OkCommand_OnExecute_CompletesInteraction()
        {
            var viewModel   = new EncryptionPasswordViewModel(new EncryptionPasswordsWindowTranslation());
            var interaction = new EncryptionPasswordInteraction(false, true, true);

            var helper = new InteractionHelper <EncryptionPasswordInteraction>(viewModel, interaction);

            viewModel.OkCommand.Execute(null);

            Assert.AreEqual(PasswordResult.StorePassword, interaction.Response);
            Assert.IsTrue(helper.InteractionIsFinished);
        }
Exemplo n.º 6
0
        public EncryptionPasswordsWindow(EncryptionPasswordViewModel viewModel)
        {
            _viewModel  = viewModel;
            DataContext = _viewModel;

            Loaded += (sender, e) =>
                      MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));

            InitializeComponent();

            _viewModel.SetPasswordInUi = SetPasswords;
        }
        public void RemoveCommand_OnExecute_CompletesInteraction()
        {
            var viewModel   = new EncryptionPasswordViewModel();
            var interaction = new EncryptionPasswordInteraction(false, true, true);
            var helper      = new InteractionHelper <EncryptionPasswordInteraction>(viewModel, interaction);

            viewModel.RemoveCommand.Execute(null);

            Assert.AreEqual(PasswordResult.RemovePassword, interaction.Response);
            Assert.IsTrue(helper.InteractionIsFinished);
            Assert.AreEqual("", interaction.OwnerPassword);
            Assert.AreEqual("", interaction.UserPassword);
        }
Exemplo n.º 8
0
        public void SetingUserPassword_WritesToInteractionAndCallsCanExecuteChanged()
        {
            var viewModel         = new EncryptionPasswordViewModel(new EncryptionPasswordsWindowTranslation());
            var canExecuteChanged = false;

            viewModel.OkCommand.CanExecuteChanged += (sender, args) => canExecuteChanged = true;
            var interaction = new EncryptionPasswordInteraction(false, true, true);

            viewModel.SetInteraction(interaction);

            viewModel.UserPassword = "******";

            Assert.AreEqual("MyPassword", interaction.UserPassword);
            Assert.IsTrue(canExecuteChanged);
        }
Exemplo n.º 9
0
        public void OkCommand_CanExecute_IfInteractionIsNotSet_ReturnsFalse()
        {
            var viewModel = new EncryptionPasswordViewModel(new EncryptionPasswordsWindowTranslation());

            Assert.IsFalse(viewModel.OkCommand.CanExecute(null));
        }