Ejemplo n.º 1
0
        public void ShouldNotBuildWhenCustomBuildPathIsSet()
        {
            Environment.SetEnvironmentVariable("GAUGE_CUSTOM_BUILD_PATH", "GAUGE_CUSTOM_BUILD_PATH");
            _startCommand.Execute();

            _mockGaugeProjectBuilder.Verify(builder => builder.BuildTargetGaugeProject(), Times.Never);
        }
Ejemplo n.º 2
0
        public void ShouldNotBuildWhenCustomBuildPathIsSet()
        {
            Environment.SetEnvironmentVariable("gauge_custom_build_path", "gauge_custom_build_path");
            _startCommand.Execute();

            _mockGaugeProjectBuilder.Verify(builder => builder.BuildTargetGaugeProject(), Times.Never);
        }
        public async Task ExecuteCommandIfMatched_ShouldNotSendMessages_ChatAlreadyExists()
        {
            //Arrange
            SetupMessageSendingMock();

            SetupRepoToContainChat();

            Update update = GetUpdate();
            //Act
            await _sut.Execute(update);

            //Assert
            AssertMessageNotBeenSend();
        }
Ejemplo n.º 4
0
        public void Execute_InitiallyStarted_ServiceIsRunning()
        {
            //Ensure the service is started
            var service = new ServiceController(SERVICE_NAME);
            var timeout = TimeSpan.FromMilliseconds(5000);

            if (service.Status != ServiceControllerStatus.Running)
            {
                service.Start();
            }
            service.WaitForStatus(ServiceControllerStatus.Running, timeout);

            //Mock the args and setup command
            var args = Mock.Of <IStartCommandArgs>(
                start => start.ServiceName == new LiteralScalarResolver <string>(SERVICE_NAME) &&
                start.TimeOut == new LiteralScalarResolver <int>("5000")
                );
            var command = new StartCommand(args);

            //Apply the test
            command.Execute();

            //Assert
            service.Refresh();
            Assert.That(service.Status, Is.EqualTo(ServiceControllerStatus.Running));
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void BotOnMessageReceived(object sender, MessageEventArgs e)
        {
            var userRepository = new UserRepository();
            var user           = userRepository.FindUser(e.Message.Chat.Id);

            switch (e.Message.Text)
            {
            case "/start":
                var startCommand = new StartCommand();
                startCommand.Execute(e.Message, user);
                return;

            case "/menu":
                var menuCommand = new MenuCommand();
                menuCommand.Execute(e.Message, user);
                break;
            }

            var command = CommandFactory.GetPublicCommand(e.Message.Text);

            if (command != null)
            {
                command.Execute(e.Message, user);
                return;
            }

            command = CommandFactory.GetCommand(user?.Command);
            command?.Execute(e.Message, user);
        }
Ejemplo n.º 6
0
        public static void Setup(TestContext context)
        {
            if (session != null)
            {
                return;
            }

            if (!IsWinAppDriverRunning())
            {
                Assert.Inconclusive("WinAppDriver.exe is not running");
            }

            LaunchApplicationAndAttach();

            Assert.IsNotNull(session);
            Assert.IsNotNull(session.SessionId);

            // Set implicit timeout to 1.5 seconds to ensure element search retries every 500 ms for at most three times
            session.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(1.5);

            var result = StartCommand.Execute(new Dictionary <string, string>(), string.Empty);

            if (!result.Succeeded)
            {
                Assert.Inconclusive("Start command for AxeWindows failed");
            }
        }
Ejemplo n.º 7
0
        private async Task ExecuteReturnsNewUserIsAdded()
        {
            //Arrange
            var mocks = GetMocks();

            var users = GetUsers().AsQueryable().BuildMock();

            SetSettingsInDb(mocks.userMock, users);

            mocks.dbMock.Setup(m => m.Users).Returns(mocks.userMock.Object);
            var startCommand = new StartCommand(mocks.dbMock.Object);
            var message      = new Message()
            {
                Chat = new Chat()
                {
                    Id = 2
                },
                From = new Telegram.Bot.Types.User()
                {
                    Username  = "******",
                    FirstName = "Test",
                    LastName  = "Test"
                }
            };

            var client = new TelegramBotClient(AppConfig.Token);

            //Act
            var result = await startCommand.Execute(message, client);

            //Assert
            Assert.NotNull(result);
            Assert.True(result.isSuccessed);
            Assert.Equal("User have been added", result.Message);
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            var arguments = ParseCommandLine(args);

            var loader          = new AssemblyLoader();
            var dbProvider      = loader.CreateTypeFromAssembly <DbProvider>(arguments["dbp.provider"], arguments);
            var dbCodeFormatter = loader.CreateTypeFromAssembly <DbTraceCodeFormatter>(arguments["tcf.provider"], arguments);
            var codeHighlighter = loader.CreateTypeFromAssembly <HighlightCodeProvider>(arguments["hcp.provider"], arguments);
            var outputProvider  = loader.CreateTypeFromAssembly <OutputProvider>(arguments["out.provider"], arguments);

            var command = arguments["app.command"].ToLower().Trim();

            // Get trace name from provided, last trace, or generate one.
            string traceName = null;

            if (arguments.ContainsKey("app.traceName"))
            {
                traceName = arguments["app.traceName"];
            }
            if (traceName == null && command != "start")
            {
                traceName = dbProvider.GetLastTraceName();
            }
            else if (traceName == null && command == "start")
            {
                traceName = DateTime.Now.ToString("yyyyMMddHHmmss");
            }

            // Get the specific database object name to run against, if specified (mainly used for testing).
            if (arguments.ContainsKey("test.objectname"))
            {
                var objectName = arguments["test.objectname"];
                dbProvider.SetSpecificObjectNameForTesting(objectName);
            }

            switch (command)
            {
            case "generate":
                var generateCommand = new GenerateOutputCommand(dbProvider, dbCodeFormatter, codeHighlighter, outputProvider, traceName);
                generateCommand.Execute();
                break;

            case "start":
                var startCommand = new StartCommand(outputProvider, dbProvider, traceName);
                startCommand.Execute();
                break;

            case "stop":
                var stopCommand = new StopCommand(dbProvider, outputProvider, traceName);
                stopCommand.Execute();
                break;

            case "finish":
                new GenerateOutputCommand(dbProvider, dbCodeFormatter, codeHighlighter, outputProvider, traceName).Execute();
                new StopCommand(dbProvider, outputProvider, traceName).Execute();
                break;
            }
        }
Ejemplo n.º 9
0
 private void ExecuteWindowLoadedCommand()
 {
     LoadStartScript();
     LoadStopScript();
     if (Settings.Default.LaunchScriptAtStartup)
     {
         StartCommand.Execute(null);
     }
 }
        public void ShouldBeAbleToCreateMatrixOfDifferentTypes(string matrixType)
        {
            var startCommand = new StartCommand(MinesweeperEngine.Instance, this.matrix, this.player, new MatrixDirector(), new MediumMatrixBuilder(), this.printer);

            ICommandInfo commandInfo = new CommandInfo(string.Empty, new List <string>()
            {
                matrixType
            });

            Assert.DoesNotThrow(() => startCommand.Execute(commandInfo));
        }
        public void ShouldThrowWhenInvalidMatrixTypeIsPassed()
        {
            var startCommand = new StartCommand(MinesweeperEngine.Instance, this.matrix, this.player, new MatrixDirector(), new MediumMatrixBuilder(), this.printer);

            ICommandInfo command = new CommandInfo(string.Empty, new List <string>()
            {
                "invalid type"
            });

            Assert.Throws(typeof(ArgumentOutOfRangeException), () => startCommand.Execute(command));
        }
Ejemplo n.º 12
0
        public void HoverCommand_ShouldExecuteClientStart()
        {
            // arrange
            startCommand = new StartCommand(DroneClientMock.Object);

            // act
            startCommand.Execute();

            // assert
            DroneClientMock.Verify(x => x.Start(), Times.Once);
        }
Ejemplo n.º 13
0
 private void OnPressed(object sender, EventArgs e)
 {
     if (StartCommand == null)
     {
         return;
     }
     if (StartCommand.CanExecute(BindingContext))
     {
         StartCommand.Execute(BindingContext);
     }
 }
Ejemplo n.º 14
0
    public async Task ShouldReturnSuccessfulResult()
    {
        var command = new StartCommand();
        var message = GenerateMessage(DefaultUser.Id, DefaultUser.Id, command.Aliases[0]);

        var result = await command.Execute(message, DefaultUser);

        result.Should().BeOfType <SuccessfulResult>();
        result.Message.Should().NotBeNullOrEmpty();
        result.Keyboard.Should().NotBeNull();
    }
Ejemplo n.º 15
0
        public void TaskShouldBeStartedThenStopped()
        {
            var task    = mokeData.GetUserTaskList(Guid.Empty).First();
            var command = new StartCommand(task);

            command.Execute();
            Assert.That(task.State, Is.EqualTo(TaskState.Started));

            command.Undo();
            Assert.That(task.State, Is.EqualTo(TaskState.Stopped));
        }
Ejemplo n.º 16
0
 /// <summary>
 /// 如果未安装,则安装,如果需要更新则更新,如果能运行则运行,只执行一个步骤
 /// </summary>
 private void updateOrStart()
 {
     if (IsNeedUpdate)
     {
         UpdateCommand.Execute(null);
     }
     else
     {
         StartCommand.Execute(null);
     }
 }
Ejemplo n.º 17
0
        public void TaskShouldBeStartedThenFinished()
        {
            var task          = mokeData.GetUserTaskList(Guid.Empty).First();
            var startCommand  = new StartCommand(task);
            var finishCommand = new FinishCommand(task);

            startCommand.Execute();
            Assert.That(task.State, Is.EqualTo(TaskState.Started));

            finishCommand.Execute();
            Assert.That(task.State, Is.EqualTo(TaskState.Done));
        }
Ejemplo n.º 18
0
        public async Task Execute()
        {
            var log   = A.Fake <ILogger>();
            var radio = A.Fake <IRadio>();

            var command = new StartCommand(log, radio);

            var result = await command.Execute(new string[0]);

            A.CallTo(() => radio.Start()).MustHaveHappened();
            Assert.Equal(CommandResult.OK, result);
        }
Ejemplo n.º 19
0
        static void Main(string[] args)
        {
            var arguments = ParseCommandLine(args);

            RequiredAttributes(arguments,
                               "databaseProvider",
                               "codeFormatProvider",
                               "codeHighlightProvider",
                               "outputProvider",
                               "action"
                               );

            var loader          = new AssemblyLoader();
            var dbProvider      = loader.CreateTypeFromAssembly <DbProvider>(arguments["databaseProvider"], arguments);
            var dbCodeFormatter = loader.CreateTypeFromAssembly <DbTraceCodeFormatter>(arguments["codeFormatProvider"], arguments);
            var codeHighlighter = loader.CreateTypeFromAssembly <HighlightCodeProvider>(arguments["codeHighlightProvider"], arguments);
            var outputProvider  = loader.CreateTypeFromAssembly <OutputProvider>(arguments["outputProvider"], arguments);

            var command = arguments["action"].ToLower().Trim();

            var traceName = arguments.ContainsKey("traceFileName") ? arguments["traceFileName"] : null;

            switch (command)
            {
            case "generate":

                RequiredAttributes(arguments,
                                   "traceFileName"
                                   );

                var generateCommand = new GenerateOutputCommand(dbProvider, dbCodeFormatter, codeHighlighter, outputProvider, traceName);
                generateCommand.Execute();
                break;

            case "execute":

                RequiredAttributes(arguments,
                                   "target"
                                   );

                traceName = traceName ?? DateTime.Now.ToString("yyyyMMddHHmmss");
                var startCommand = new StartCommand(outputProvider, dbProvider, traceName);
                startCommand.Execute();

                var executeCommand = new ExecuteCommand(arguments["target"], arguments.ContainsKey("targetArgs") ? arguments["targetArgs"] : string.Empty);
                executeCommand.Execute();

                var stopCommand = new StopCommand(dbProvider, outputProvider, traceName);
                stopCommand.Execute();

                break;
            }
        }
Ejemplo n.º 20
0
        public void Start_Execute_ReturnsConnectionFailed()
        {
            _engine.Setup(e => e.CheckApiConnection()).ReturnsAsync(false);

            var console = new TestConsole(_output);
            var command = new StartCommand(_engine.Object, _engineConfig.Object, console,
                                           (new Mock <ILogger <StartCommand> >()).Object);

            var exception = Record.Exception(() => command.Execute());

            Assert.Equal($"Connection to {ApiUrl} was failed.", exception?.Message);
        }
Ejemplo n.º 21
0
        public async Task <OkResult> Update([FromBody] Update update) // Handling bot updates
        {
            var message = update.Message;
            var courier = _dbContext.Couriers.FirstOrDefault(c => c.TelegramUsrName == message.From.Username);
            var client  = Bot.Bot.GetClient();

            if (courier == null) // Check registration(is he courier)
            {
                await client.SendTextMessageAsync(message.Chat.Id,
                                                  "Sorry u're not registed. More info at https://github.com/RNRNRNR/deliverysystemAPI");

                return(Ok());
            }

            switch (courier.Status)
            {
            case 3:
                var confirm = new ConfirmCommand();
                if (message.Text.Contains(confirm.Name))
                {
                    confirm.Execute(message, client, _dbContext);
                }
                else
                {
                    await client.SendTextMessageAsync(message.Chat.Id, "To confirm delivery type /confirmdelivery");
                }

                break;

            case 1:
                var work = new WorkCommand();
                if (message.Text.Contains(work.Name))
                {
                    work.Execute(message, client, _dbContext);
                }
                break;

            case 2:
                await client.SendTextMessageAsync(message.Chat.Id, "Receive ur packages");

                break;

            case null:
                var start = new StartCommand();
                if (message.Text.Contains(start.Name))
                {
                    start.Execute(message, client, _dbContext);
                }
                break;
            }

            return(Ok());
        }
Ejemplo n.º 22
0
        private void OnClick(object sender, RoutedEventArgs e)
        {
            if (With is TLChannel channel)
            {
                if (channel.IsLeft)
                {
                    JoinCommand?.Execute(null);
                }
                else if (channel.HasBannedRights && channel.BannedRights.IsViewMessages)
                {
                    DeleteAndExitCommand?.Execute(null);
                }
                else
                {
                    if (channel.IsBroadcast)
                    {
                        if (channel.IsCreator || (channel.HasAdminRights && channel.AdminRights.IsPostMessages))
                        {
                        }
                        else
                        {
                            ToggleMuteCommand?.Execute(null);
                        }
                    }
                }
            }

            if (With is TLChatForbidden forbiddenChat)
            {
                DeleteAndExitCommand?.Execute(null);
            }

            if (With is TLUser user)
            {
                var full = InMemoryCacheService.Current.GetFullUser(user.Id);
                if (full != null && full.IsBlocked)
                {
                    UnblockCommand?.Execute(null);
                }

                if (user.IsBot && HasAccessToken)
                {
                    StartCommand?.Execute(null);
                }

                if (user.IsDeleted)
                {
                    DeleteAndExitCommand?.Execute(null);
                }
            }
        }
Ejemplo n.º 23
0
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            var idleTime = IdleTimeFinder.GetIdleTime();

            if (idleTime > Settings.Default.IdleTimeInMinutes * 60 * 1000 && Status == ProcessStatus.Running)
            {
                StopCommand.Execute(null);
                if (Status == ProcessStatus.Stopped)
                {
                    var result = MessageBox.Show("The StopScript was executed as ilde time was detected! Do you want to run StartScript?", "Idle time - script executed!", MessageBoxButton.YesNo);
                    if (result == MessageBoxResult.Yes)
                    {
                        StartCommand.Execute(null);
                    }
                }
            }
        }
Ejemplo n.º 24
0
        private void Start()
        {
            // Start command
            if (_time.Minute == 0 && _time.Hour == 0)
            {
                _time = _time.AddMinutes(Step);
            }

            if (XamarinHelper.CanExecuteCommand(StartCommand, _time))
            {
                StartCommand.Execute(_time);
            }

            submitButton.Text = StopText;

            IsStarted = true;
        }
Ejemplo n.º 25
0
        public void Execute_NewInstanceSucceeds_ReturnsSuccessfulResult()
        {
            using (ShimsContext.Create())
            {
                int callsToNewInstance = 0;

                ShimAutomationSession.NewInstanceCommandParametersIDisposable = (_, __) =>
                {
                    callsToNewInstance++;
                    return(new ShimAutomationSession());
                };
                StartCommandResult result = StartCommand.Execute(new Dictionary <string, string>(), string.Empty);

                Assert.AreEqual(1, callsToNewInstance);
                Assert.AreEqual(true, result.Completed);
                Assert.AreEqual(true, result.Succeeded);
                Assert.IsFalse(string.IsNullOrWhiteSpace(result.SummaryMessage));
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Initialize the scan engine
        /// </summary>
        protected override void ProcessRecord()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            if (!string.IsNullOrEmpty(this.TargetProcessId))
            {
                parameters[CommandConstStrings.TargetProcessId] = this.TargetProcessId;
            }

            if (!string.IsNullOrEmpty(this.OutputPath))
            {
                parameters[CommandConstStrings.OutputPath] = this.OutputPath;
            }

            string configFile = string.IsNullOrEmpty(this.ConfigFile) ? string.Empty : this.ConfigFile;

            using (new AppDomainAdjuster())
            {
                WriteObject(StartCommand.Execute(parameters, configFile, isPowerShell: true));
            }
        }
Ejemplo n.º 27
0
        public void Execute_NewInstanceThrowsAutomationException_ReturnsFailedResult()
        {
            const string exceptionMessage = "Hello from your local exception!";

            using (ShimsContext.Create())
            {
                int callsToNewInstance = 0;

                ShimAutomationSession.NewInstanceCommandParametersIDisposable = (_, __) =>
                {
                    callsToNewInstance++;
                    throw new A11yAutomationException(exceptionMessage);
                };

                StartCommandResult result = StartCommand.Execute(new Dictionary <string, string>(), string.Empty);

                Assert.AreEqual(1, callsToNewInstance);
                Assert.AreEqual(false, result.Completed);
                Assert.AreEqual(false, result.Succeeded);
                Assert.AreEqual(exceptionMessage, result.SummaryMessage);
            }
        }
Ejemplo n.º 28
0
        void OnVideoOutputKeyEvent(RemoteControlKeyEventArgs args)
        {
            if (!UsesEmbeddingControls)
            {
                return;
            }

            if (!_controls.Value.IsVisible)
            {
                ShowController();
                return;
            }

            if (args.KeyName == RemoteControlKeyNames.Left)
            {
                if (RewindCommand.CanExecute(null))
                {
                    args.Handled = true;
                    RewindCommand.Execute(null);
                }
            }
            else if (args.KeyName == RemoteControlKeyNames.Right)
            {
                if (FastForwardCommand.CanExecute(null))
                {
                    args.Handled = true;
                    FastForwardCommand.Execute(null);
                }
            }
            else if (args.KeyName == RemoteControlKeyNames.Return)
            {
                if (StartCommand.CanExecute(null))
                {
                    args.Handled = true;
                    StartCommand.Execute(null);
                }
            }
        }
Ejemplo n.º 29
0
        public void Create(Context context)
        {
            _context = context;
            var isSuccess = false;

            try {
                InternalCreate();
                isSuccess = true;
            } catch (Exception ex) {
                _log.WriteError(ex);
            } finally {
                StartCommand startCommand = new StartCommand(_context, _log);
                startCommand
                .SetNext(new DeleteTempFilesCommand())
                .SetNext(new DeleteSvnAuthenticationCachedItemsCommand());
                startCommand.Execute();
                if (isSuccess)
                {
                    PrintResultInfo();
                    Console.WriteLine("Work successfully done");
                }
            }
            Console.ReadLine();
        }
Ejemplo n.º 30
0
        /// <summary>
        /// This entry point does not ship, but it makes for a quick and easy way to debug through the
        /// automation code. One caveat--we intentionally don't build symbols for this app, so while you
        /// can use it to to debug the automation code, breakpoints set in this class will be ignored.
        /// </summary>
        static void Main(string[] args)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();
            string secondaryConfigFile             = string.Empty;

            char[] delimiters = { '=' };

            foreach (string arg in args)
            {
                string[] pieces = arg.Split(delimiters);
                if (pieces.Length == 2)
                {
                    string key   = pieces[0].Trim();
                    string value = pieces[1].Trim();

                    if (!string.IsNullOrWhiteSpace(key) && !string.IsNullOrWhiteSpace(value))
                    {
                        // Special case for SecondaryConfigFile
                        if (key.Equals("SecondaryConfigFile", StringComparison.OrdinalIgnoreCase))
                        {
                            secondaryConfigFile = value;
                        }
                        else
                        {
                            parameters[key] = value;
                        }
                        continue;
                    }
                }

                Console.WriteLine("Ignoring malformed input: {0}", arg);
            }
            ;

            Console.WriteLine(StartCommand.Execute(parameters, secondaryConfigFile).ToString());

            int autoFileId = 0;

            while (true)
            {
                Console.Write("Enter process ID to capture (blank to exit): ");
                string input = Console.ReadLine();

                if (string.IsNullOrEmpty(input))
                {
                    break;
                }

                if (!int.TryParse(input, out int processId))
                {
                    Console.WriteLine("Not a valid int: " + input);
                    continue;
                }

                Dictionary <string, string> snapshotParameters = new Dictionary <string, string>
                {
                    { CommandConstStrings.TargetProcessId, input },
                    { CommandConstStrings.OutputFile, autoFileId++.ToString(CultureInfo.InvariantCulture) },
                };
                Console.WriteLine(SnapshotCommand.Execute(snapshotParameters).ToString());
            }
            Console.WriteLine(StopCommand.Execute().ToString());
        }