Exemplo n.º 1
0
        public void RetryAttributeParseTest(string e2eFile, int expectedRetry)
        {
            ITestE2E e2e = CreateTestE2E(e2eFile);

            Assert.NotEmpty(e2e.Steps);
            Assert.Equal(expectedRetry, e2e.Steps[0].Retry);
        }
Exemplo n.º 2
0
 public TestE2EExecutor(ITestE2E testE2E, IComputer computer, IReadOnlyList <ICloudOCRService> ocrService, ILogger logger, IEngineConfig engineConfig)
 {
     _testE2E      = testE2E;
     _computer     = computer;
     _ocrService   = ocrService;
     _logger       = logger;
     _engineConfig = engineConfig;
 }
Exemplo n.º 3
0
        public void IsLaunchedProgramMaximizedTest(string e2eFile, bool expectedValue)
        {
            string        file   = Path.Combine(Environment.CurrentDirectory, e2eFile);
            TestE2EReader reader = new TestE2EReader(CreateLoggerMock().Object);
            ITestE2E      e2e    = reader.ReadFile(file);

            Assert.Equal(expectedValue, e2e.MakeLaunchedProgramMaximized);
        }
Exemplo n.º 4
0
        public void VerifyWaitingAndRetry(string e2eFile, int step, bool emptyWaitingTime, bool emptyRetry)
        {
            ITestE2E e2e = CreateTestE2E(e2eFile);

            Assert.NotEmpty(e2e.Steps);
            Assert.Equal(emptyWaitingTime, e2e.Steps[step].WaitingSecond == 0);
            Assert.Equal(emptyRetry, e2e.Steps[step].Retry == 0);
        }
Exemplo n.º 5
0
        public void TestStepCountTest(string e2eFile, int expectedCount)
        {
            string        file   = Path.Combine(Environment.CurrentDirectory, e2eFile);
            TestE2EReader reader = new TestE2EReader(CreateLoggerMock().Object);
            ITestE2E      e2e    = reader.ReadFile(file);

            Assert.Equal(expectedCount, e2e.Steps.Count);
        }
Exemplo n.º 6
0
        public void SearchScreenAreaTest(string e2eFile, int stepIndex, List <ScreenSearchArea> expectedAreas)
        {
            string        file   = Path.Combine(Environment.CurrentDirectory, e2eFile);
            TestE2EReader reader = new TestE2EReader(CreateLoggerMock().Object);
            ITestE2E      e2e    = reader.ReadFile(file);

            IReadOnlyList <ScreenSearchArea> actualAreas = e2e.Steps[stepIndex].SearchArea;

            Assert.Equal(expectedAreas, actualAreas);
        }
Exemplo n.º 7
0
        public void ParseSuccessTest(string e2eFile,
                                     string expectedShortName,
                                     bool expectedSkip,
                                     string expectedProgramToLaunch,
                                     int expectedTextSteps)
        {
            ITestE2E e2e = CreateTestE2E(e2eFile);

            Assert.Equal(expectedShortName, e2e.ShortName);
            Assert.Equal(expectedSkip, e2e.Skip);
            Assert.Equal(expectedProgramToLaunch, e2e.ProgramToLaunch);
            Assert.NotNull(e2e.Steps);
            Assert.Equal(expectedTextSteps, e2e.Steps.Count);
        }
Exemplo n.º 8
0
        public void EnvironmentVariableTest(string e2eFile, string environmentName, string expectedValue)
        {
            string originalValue = Environment.GetEnvironmentVariable(environmentName);

            Environment.SetEnvironmentVariable(environmentName, expectedValue);
            string        file   = Path.Combine(Environment.CurrentDirectory, e2eFile);
            TestE2EReader reader = new TestE2EReader(CreateLoggerMock().Object);
            ITestE2E      e2e    = reader.ReadFile(file);

            // according to this e2e file, get the first step and get its ActionArgument
            Assert.Equal(expectedValue, e2e.Steps[0].ActionArgument);

            // revert environment variable
            Environment.SetEnvironmentVariable(environmentName, originalValue);
        }
Exemplo n.º 9
0
        public async Task RunAsync(string[] e2eFiles = null)
        {
            if (e2eFiles == null || e2eFiles.Length == 0)
            {
                PrintHelpMessage();
                return;
            }

            bool finalResult = true;

            for (int i = 0; i < e2eFiles.Length; i++)
            {
                if (string.IsNullOrEmpty(e2eFiles[i]) || !File.Exists(e2eFiles[i]))
                {
                    _logger.WriteError(string.Format(EngineResource.FileNotExist, e2eFiles[i]));
                    continue;
                }

                try
                {
                    ITestE2E teste2e = _testE2EReader.ReadFile(e2eFiles[i]);

                    if (teste2e.Skip)
                    {
                        continue;
                    }

                    _logger.WriteInfo(string.Format(EngineResource.RunTestHeaderMessage, teste2e.FullName));

                    TestE2EExecutor executor = new TestE2EExecutor(teste2e, _computer, _ocrServices, _logger, _engineConfig);
                    bool            result   = await executor.ExecuteAsync().ConfigureAwait(false);

                    finalResult &= result;

                    _logger.WriteInfo(string.Format(EngineResource.RunTestFinalMessage, teste2e.FullName, result));
                }
                catch (Exception ex)
                {
                    _logger.WriteError($"{EngineResource.EngineErrorMessagePrefix} {ex}");
                }
            }

            DisplayFinalResult(finalResult);
        }