コード例 #1
0
 public static void ReadSingleExecutionCounts(SingleExecutionFull exec)
 {
     try
     {
         var buys = GetBuys();
         foreach (var buy in buys)
         {
             SingleExecutionCounts buyCounts = ReadOneBuyGroupCounts(buy);
             exec.ResultCounts.Add(buyCounts);
         }
     }
     catch (Exception x)
     {
         XLogger.Error(x);
     }
 }
コード例 #2
0
        public List <SingleExecutionFull> GetExecSteps()
        {
            var res = new List <SingleExecutionFull>();
            TestElementAction action = null;

            try
            {
                for (int i = 0; i < TestActions.Count; i++)
                {
                    action = TestActions[i];
                    SingleExecutionFull currentExec = GetInitialExecStep();
                    currentExec.AssociatedAction = action;
                    res.Add(currentExec);
                }

                return(res);
            }
            catch (Exception x)
            {
                x.Data.Add("action", action);
                throw;
            }
        }
コード例 #3
0
        public SingleExecutionFull GetInitialExecStep()
        {
            try
            {
                var res = new SingleExecutionFull()
                {
                    Ticker           = Ticker,
                    DaysToExpiration = DaysToExpiration,
                    TestLength       = TestLength
                };

                foreach (var action in InitialActions)
                {
                    res.AssociatedAction = action;
                }

                return(res);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #4
0
        private static bool ImplementActiveTest()
        {
            TimeSpan timespan;

            try
            {
                currentStep = "Reading Test configuration";
                CallUpdateStatus(currentStep);
                string defaultTestConfigPath = Path.GetFullPath(String.Format(@"testConfigs\{0}.json", Variables.ActiveTest));
                var    defaultTestConfig     = TestConfiguration.ReadTestConfiguration(defaultTestConfigPath);

                currentStep = "Implementing initial test actions";
                CallUpdateStatus(currentStep);
                Selenium.EditTextField(Identifiers.TextFields["DaysToExpiration"], defaultTestConfig.DaysToExpiration.ToString());
                Selenium.ClickField(Identifiers.Buttons[defaultTestConfig.TestLength]);

                Stopwatch swInitial = new Stopwatch();
                swInitial.Start();
                foreach (var action in defaultTestConfig.InitialActions)
                {
                    action.ImplementTestAction();
                }
                Selenium.EditTextField(Identifiers.TextFields["Ticker"], defaultTestConfig.Ticker);
                Selenium.PressEnterInTextField(Identifiers.TextFields["Ticker"]);

                if (!Selenium.ConfirmReady())
                {
                    throw new ApplicationException($"{currentStep}: Charts were not loaded. A timeout may have occured");
                }

                if (!Selenium.ConfirmValidConfiguration())
                {
                    HaltExecution();
                    throw new ApplicationException("Test configuration is invalid, therefore no data was loaded and the simulation stopped.");
                }

                SingleExecutionFull initExec = defaultTestConfig.GetInitialExecStep();
                timespan = swInitial.Elapsed;
                swInitial.Stop();
                string total = timespan.ToStandardElapsedFormat();
                initExec.TOTAL = total;
                Lookups.Executions.Add(initExec);
                Selenium.ReadSingleExecutionCounts(initExec);

                currentStep = "Implementing Test actions";
                CallUpdateStatus(currentStep);

                //execSteps
                var execSteps            = defaultTestConfig.GetExecSteps();
                SingleExecutionFull exec = new SingleExecutionFull();
                for (int i = 0; i < execSteps.Count; i++)
                {
                    exec = execSteps[i];
                    if (Engine.Variables.CancellationPending)
                    {
                        HaltExecution(); return(true);
                    }

                    if (exec.AssociatedAction == null)
                    {
                        continue;
                    }

                    currentStep = exec.AssociatedAction.ElementId;
                    CallUpdateStatus(currentStep);
                    Stopwatch swCurrent = new Stopwatch();
                    swCurrent.Start();
                    exec.AssociatedAction.ImplementTestAction();

                    if (!Selenium.ConfirmValidConfiguration())
                    {
                        HaltExecution();
                        throw new ApplicationException("Test configuration is invalid, therefore no data was loaded and the simulation stopped.");
                    }

                    if (!Selenium.ConfirmReady())
                    {
                        throw new ApplicationException($"{currentStep}: Charts were not loaded. A timeout may have occured");
                    }

                    timespan = swCurrent.Elapsed;
                    swCurrent.Stop();
                    exec.TOTAL = timespan.ToStandardElapsedFormat();
                    Lookups.Executions.Add(exec);
                    Selenium.ReadSingleExecutionCounts(exec);
                }

                return(true);
            }
            catch (Exception x)
            {
                if (x.Data.Contains(currentStep))
                {
                    x.Data.Add("currentStep", currentStep);
                }
                throw;
            }
        }