Esempio n. 1
0
 private void YT_TextBox_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (!(bool)e.NewValue)
     {
         BindingExpression binding = GetBindingExpression(TextBox.TextProperty);
         binding?.UpdateSource();
         RoutedCommand rcmd = DisableCommand as RoutedCommand;
         if (rcmd != null)
         {
             if (rcmd.CanExecute(CommandParameter, CommandTarget))
             {
                 rcmd.Execute(CommandParameter, CommandTarget);
             }
         }
         else
         {
             if (DisableCommand != null)
             {
                 if (DisableCommand.CanExecute(CommandParameter))
                 {
                     DisableCommand.Execute(CommandParameter);
                 }
             }
         }
     }
 }
Esempio n. 2
0
        public void CallsReset()
        {
            var viewModel = Mock.Of <IViewModel>();
            var settings  = Mock.Of <IBeamgunSettings>();
            var command   = new DisableCommand(viewModel, settings);

            command.Execute(null);

            Mock.Get(viewModel).Verify(x => x.Reset());
        }
Esempio n. 3
0
        public void AccountTwoFactorDisable_Execute_ReturnsSuccessMessage()
        {
            _accountService.Setup(s => s.DisableTwoFactor()).Returns(Task.CompletedTask);

            var console = new TestConsole(_output, "y");
            var command = new DisableCommand(console, LoggerMock.GetLogger <DisableCommand>().Object, _accountService.Object);

            var resultMessage = command.Execute();

            Assert.Equal("2fa has been disabled", resultMessage);
        }
Esempio n. 4
0
        public void CallsDisable()
        {
            const double waitTime  = 100;
            var          viewModel = Mock.Of <IViewModel>();
            var          settings  = Mock.Of <IBeamgunSettings>(x => x.DisableTime == waitTime);
            var          command   = new DisableCommand(viewModel, settings);

            command.Execute(null);

            var lower = DateTime.Now.AddMinutes(waitTime - 1);
            var upper = DateTime.Now.AddMinutes(waitTime + 1);

            Mock.Get(viewModel).Verify(x => x.DisableUntil(It.IsInRange(lower, upper, Range.Exclusive)));
        }