コード例 #1
0
        public void Execute(ExecutionPlan plan)
        {
            var query    = new StringBuilder();
            var cmd      = Connection.CreateCommand();
            var nbParams = 0;

            Connection.Open();
            using (var transaction = Connection.BeginTransaction())
            {
                var cancel = false;

                foreach (var step in plan.InsertSteps)
                {
                    GemerateInsertStatment(step, cmd, query, transaction, ref nbParams);
                    TryExecute(plan, query, transaction, ref cmd, ref nbParams, ref cancel);
                }

                foreach (var step in plan.UpdateSteps)
                {
                    GemerateUpdateStatment(step, cmd, query);
                    TryExecute(plan, query, transaction, ref cmd, ref nbParams, ref cancel);
                }

                //Flush
                Execute(plan, query, transaction, cmd, ref cancel);

                if (!cancel)
                {
                    transaction.Commit();
                }
            }
            Connection.Close();
        }
コード例 #2
0
ファイル: ExecutionPlanTests.cs プロジェクト: samieze/aMuSE
        void test_sampleA_SourceByNodeID()
        {
            ExecutionPlan executionPlan = new ExecutionPlan(new InputSamples().sampleA);

            var e0 = "B C D SEQ(A,B) SEQ(A,C) SEQ(B,D) SEQ(AND(B,C),D) SEQ(A,AND(B,C),D)".Split(' ');
            var e1 = "B C A SEQ(A,B) SEQ(A,C) SEQ(B,D) SEQ(AND(B,C),D) SEQ(A,AND(B,C),D)".Split(' ');
            var e2 = "B D A SEQ(A,B) SEQ(B,D)".Split(' ');
            var e3 = "C D SEQ(A,C) SEQ(AND(B,C),D)".Split(' ');
            var e4 = "D A".Split(' ');

            var expectedlist = new List <IEnumerable <string> >()
            {
                e0, e1, e2, e3, e4
            };

            for (int i = 0; i < 5; i++)
            {
                List <string> actual = new List <string>();
                foreach (var item in executionPlan.sourceNodesByEventName)
                {
                    if (item.Value.Contains(new NodeName(i.ToString())))
                    {
                        actual.Add(item.Key.ToString());
                    }
                }
                Assert.Equal(expectedlist[i], actual);
            }
        }
コード例 #3
0
        /// <summary>
        /// Displays the given ExecutionPlans in the UI
        /// </summary>
        /// <param name="executionPlans">The ExecutionPlans to display in the UI.</param>
        public void Setup(List <ExecutionPlan> executionPlans)
        {
            if (executionPlans == null)
            {
                return;
            }

            Debug.Log($"Setting up UI for list of execution plans with length {executionPlans.Count}:\n    ● {executionPlans.ToStringAllElements("\n    ● ")}\n", gameObject);

            // Instantiate missing UI elements
            int missingUIElements = executionPlans.Count - executionPlanUIs.Count;

            for (int e = 0; e < missingUIElements; e++)
            {
                GameObject      spawnedExecutionPlanUI = Instantiate(executionPlanUIPrefab, this.transform);
                ExecutionPlanUI executionPlanUI        = spawnedExecutionPlanUI.GetComponentRequired <ExecutionPlanUI>();
                executionPlanUIs.Add(executionPlanUI);
            }

            // Configure the UI elements
            for (int e = 0; e < executionPlanUIs.Count; e++)
            {
                ExecutionPlan executionPlanToDisplay = executionPlans.Count > e ? executionPlans[e] : null;
                executionPlanUIs[e].Setup(executionPlanToDisplay);
            }
        }
コード例 #4
0
ファイル: ExecutionPlanTests.cs プロジェクト: samieze/aMuSE
        void test_sampleA_ForwardRules()
        {
            ExecutionPlan executionPlan = new ExecutionPlan(new InputSamples().sampleA);

            var expectations = new List <(string, string, string)>()
            {
                ("0", "D", "1 2"),
                ("0", "SEQ(B,D)", "1 3"),
                ("0", "SEQ(A,B)", "1"),
                ("0", "SEQ(A,C)", "1"),
                ("1", "A", "0 2 3"),
                ("1", "SEQ(B,D)", "0 3"),
                ("1", "SEQ(A,B)", "0"),
                ("1", "SEQ(A,C)", "0"),
                ("2", "A", "0 1 3"),
                ("2", "D", "0 1"),
                ("2", "SEQ(B,D)", "0 1 3"),
                ("2", "SEQ(A,B)", "0 1"),
                ("3", "D", "0 1 2"),
                ("3", "SEQ(A,C)", "0 1"),
                ("3", "SEQ(AND(B,C),D)", "0"),
                ("4", "A", "0 1 2 3"),
                ("4", "D", "0 1 2")
            };

            var fr = executionPlan.forwardRulesByNodeName;

            foreach (var item in expectations)
            {
                Assert.Equal(item.Item3.Split(' ').Select(x => new NodeName(x)),
                             fr[new NodeName(item.Item1)][new EventType(item.Item2)].destinations);
            }
        }
コード例 #5
0
        public void ExecutionPlan_2Stages_Success()
        {
            // A. Setup
            ExecutionPlan executionPlan = new ExecutionPlan();
            CISession     ciSession     = new CISession();

            const string stage_01 = "st01";
            const string stage_02 = "st02";
            const string stage_03 = "st03";
            const string stage_04 = "st04";


            // B. Build some Build Stages to test with
            testStageClass stage01 = new testStageClass(stage_01, ciSession);
            testStageClass stage02 = new testStageClass(stage_02, ciSession);

            // Setup predecessors
            stage02.AddPredecessor(stage_01);

            // B3 - Add to Execution plan
            executionPlan.AddKnownStage(stage01);
            executionPlan.AddKnownStage(stage02);

            // Test
            //Should be 2 steps in the plan and known stages
            executionPlan.BuildExecutionPlan(stage_02);

            // Validate
            Assert.AreEqual(2, executionPlan.KnownStages.Count, "A10: ");
            Assert.AreEqual(2, executionPlan.Plan.Count, "A20: ");

            // Validate the plan sequence
            Assert.AreEqual(stage01, executionPlan.Plan.First.Value, "A30:");
            Assert.AreEqual(stage02, executionPlan.Plan.First.Next.Value, "A40:");
        }
コード例 #6
0
        private void Execute(ExecutionPlan plan, StringBuilder query, IDbTransaction transaction,
                             IDbCommand cmd, ref bool cancel)
        {
            if (query.Length <= 0)
            {
                return;
            }

            //We start a new batch
            cmd.CommandText = query.ToString();
            cmd.Transaction = transaction;

            //Exec query
            using (var dr = cmd.ExecuteReader())
                RetriveAutoGeneratedPk(plan, dr);

            if (QueryCommmiting != null)
            {
                var args = new QueryCommitingEventArgs(cmd);
                QueryCommmiting(null, args);
                if (args.Cancel)
                {
                    cancel = true;
                }
            }
        }
コード例 #7
0
        public void ExecutionPlan_HasSummonAndDesitnationDescOrder_WhenSummonedFrom2FloorsToGoDownAndParkedLowerThanBothAndRequestImmediatlyFollowSummonAnd1RequestIsExtremumFloor()
        {
            FloorConfiguration floorConfig     = new FloorConfiguration(3, 0, 15);
            IExecutionPlan     plan            = new ExecutionPlan();
            ILift                     lift     = new Lift(floorConfig, plan);
            SummonInformation         summon1  = new SummonInformation(15, TravelDirection.Down);
            SummonInformation         request1 = new SummonInformation(1, TravelDirection.None, summon1);
            SummonInformation         summon2  = new SummonInformation(4, TravelDirection.Down);
            SummonInformation         request2 = new SummonInformation(1, TravelDirection.None, summon2);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                summon1,
                request1,
                summon2,
                request2
            };

            var executionPlan = lift.ProcessRequests(requests);

            var planResult = executionPlan.GetFloorVisitationPlan();

            Assert.Equal(summon1.SummonFloor, planResult.ElementAt(0));
            Assert.Equal(summon2.SummonFloor, planResult.ElementAt(1));
            Assert.Equal(request1.SummonFloor, planResult.ElementAt(2));
        }
コード例 #8
0
        public override void ExitOn_root_command([NotNull] CrawlLangParser.On_root_commandContext context)
        {
            List <ICommand> commands = _CurrentBlock;

            _BlockIds.Pop();

            ExecutionPlan = new ExecutionPlan(commands, _RootURL);
        }
コード例 #9
0
ファイル: ExecutionPlanTests.cs プロジェクト: samieze/aMuSE
        public void test_sampleA_processedAllQueries()
        {
            ExecutionPlan executionPlan = new ExecutionPlan(new InputSamples().sampleA);

            foreach (var item in executionPlan.wasQueryProcessed)
            {
                Assert.True(item.Value, "Query " + item.Key.ToString() + " was not processed.");
            }
        }
コード例 #10
0
        public void test_DCEPNodeInstantiation_SampleA()
        {
            ExecutionPlan executionPlan = new ExecutionPlan(new InputSamples().sampleA);

            foreach (var item in executionPlan.networkPlan)
            {
                var node = new DCEPNode(item.Key, new InputSamples().sampleA, new DCEPSettings());
            }
        }
コード例 #11
0
        public async Task <SpecResults> Execute(ExecutionPlan plan)
        {
            _observer.Starting(plan);

            /* TODOs
             *
             * 1. Try/Catch around the creation of the context. If it fails, the running is invalid.
             *  Return a results for that problem
             *
             * 2. Check if the runner is in an invalid state. If so, bail out
             *
             * 3. Start a timings object
             * 4. Create a timings object for creating the context
             * 5. If no steps at all in the execution plan, log an exception about the spec
             *  not being real
             *
             *
             * 6. Need to redirect the debug and trace output to the context
             * 7. Do a timeout where you start a parallel task and wait both
             *
             * 8. Build the results
             *  a. check for a catastropic exception
             *  b. mark if the spec completed
             *  c. timings.Finish()
             *  d. log the final result
             *
             * 9. cancel the context
             * 10. Finalize the results
             */

            var context = await _system.CreateContext(plan.Specification);


            // Need to check if the context itself is invalid before going on
            foreach (var line in plan.Lines)
            {
                // This is going to be it. All smarts in the new ExecutionContext
                if (context.Cancellation.IsCancellationRequested)
                {
                    break;
                }

                // TODO -- trap exceptions inside of line itself
                // TODO -- if line captures a critical or catastrophic exception,
                // kill the spec
                var result = await line.Execute(context);

                _observer.Completed(plan, line, result);
            }


            await _system.Complete(context);


            _observer.Finished(plan, new SpecResults());
            throw new NotImplementedException();
        }
コード例 #12
0
        public void Lift_MustThrowException_WhenNoRequestIsMade()
        {
            FloorConfiguration floorConfig = new FloorConfiguration(3, 0, 15);
            IExecutionPlan     plan        = new ExecutionPlan();
            ILift lift = new Lift(floorConfig, plan);
            IList <SummonInformation> requests = new List <SummonInformation>();

            Assert.Throws <ArgumentException>(() => lift.ProcessRequests(requests));
        }
コード例 #13
0
        public void Lift_CanaryTest()
        {
            FloorConfiguration floorConfig = new FloorConfiguration(3, 0, 15);
            IExecutionPlan     plan        = new ExecutionPlan();

            ILift lift = new Lift(floorConfig, plan);

            Assert.NotNull(lift);
            Assert.Equal(floorConfig.CurrentFloor, lift.CurrentFloor);
        }
コード例 #14
0
        /// <summary>
        /// Displays the given execution plan in the UI
        /// </summary>
        /// <param name="executionPlan">The ExecutionPlan to display in the UI.</param>
        public void Setup(ExecutionPlan executionPlan)
        {
            bool display = executionPlan != null;

            gameObject.SetActive(display);

            if (display)
            {
                executionPlanText.text = executionPlan.mapEvent.name;
            }
        }
コード例 #15
0
        public void StartScript(string scriptText)
        {
            using (_SeleniumExecutionEngine = new SeleniumExecution.SeleniumExecutionEngine(RunOptions.WebDriverPath, new SeleniumExecutionEngineOptions()
            {
                DisableWebSecurity = RunOptions.DisableWebSecurity, RunHeadlessBrowser = RunOptions.NoBrowser
            }))
            {
                _CrawlLangEngine = new CrawlLangEngine(scriptText, _SeleniumExecutionEngine);
                _CrawlLangEngine.ParseScript();
                if (_CrawlLangEngine.HasErrors)
                {
                    ErrorMessages = _CrawlLangEngine.Errors;
                }
                else
                {
                    ExecutionPlan plan = _CrawlLangEngine.GenerateExecutionPlan();
                    try
                    {
                        _SeleniumExecutionEngine.StartEngine();

                        IsRunning = true;
                        OutputSingleton.ClearAllOutputters();
                        if (!string.IsNullOrWhiteSpace(RunOptions.OutputFilePath))
                        {
                            CreepyCrawly.Output.OutputSingleton.CreateFileTextOutputter(RunOptions.OutputFilePath);
                        }
                        if (!string.IsNullOrWhiteSpace(RunOptions.ImageOutputDirectory))
                        {
                            CreepyCrawly.Output.OutputSingleton.CreateImageFileOutputter(RunOptions.ImageOutputDirectory);
                        }
                        CreepyCrawly.Output.OutputSingleton.CreateStringOutputter();
                        CreepyCrawly.Output.OutputSingleton.AssignEventHandlerToStringOutputters(_OutputEventHandler);
                        if (_SeleniumExecutionEngine.IsEngineOk)
                        {
                            plan.Commands.ForEach(cmd =>
                            {
                                cmd.Execute();
                            });
                        }
                        else
                        {
                            CreepyCrawly.Output.OutputSingleton.WriteToStringOutputters("Engine wasn't started :(\nMaybe you are missing an appropriate chromedriver in the app root directory.");
                        }
                    }
                    catch (Exception e)
                    {
                        if (IsRunning)
                        {
                            CreepyCrawly.Output.OutputSingleton.WriteToStringOutputters(string.Format("An error occurred during script execution with message:\n{0}\nSee the following stacktrace:\n{1}", e.Message, e.StackTrace));
                        }
                    }
                }
            }
        }
コード例 #16
0
        public void Executables_ReturnsSuppliedExecutables()
        {
            var executables = new List <ProcessExecutable>()
            {
                new ProcessExecutable(new Mock <IExecutable>().Object, new ExecutableConfiguration("type", 30, null))
            };

            var executionPlan = new ExecutionPlan(executables, "integrationDir", "executablesDir");

            Assert.Equal(executables, executionPlan.Executables);
        }
コード例 #17
0
ファイル: ExecutionPlanTests.cs プロジェクト: samieze/aMuSE
        public void test_sampleA_HasForwardRules()
        {
            ExecutionPlan executionPlan = new ExecutionPlan(new InputSamples().sampleA);
            int           count         = 0;

            foreach (var item in executionPlan.forwardRulesByNodeName)
            {
                count += item.Value.Count;
            }
            Assert.True(count > 0);
        }
コード例 #18
0
ファイル: ConventionRunner.cs プロジェクト: ridecar2/fixie
        public ConventionResult Run(Convention convention, Listener listener, params Type[] candidateTypes)
        {
            var executionPlan = new ExecutionPlan(convention);
            var conventionResult = new ConventionResult(convention.GetType().FullName);

            foreach (var testClass in convention.Classes.Filter(candidateTypes))
            {
                var classResult = new ClassResult(testClass.FullName);

                var methods = convention.Methods.Filter(testClass);

                var cases = methods.SelectMany(method => CasesForMethod(convention, method)).ToArray();
                var casesBySkipState = cases.ToLookup(convention.CaseExecution.SkipPredicate);
                var casesToSkip = casesBySkipState[true];
                var casesToExecute = casesBySkipState[false];
                foreach (var @case in casesToSkip)
                {
                    var skipResult = new SkipResult(@case, convention.CaseExecution.SkipReasonProvider(@case));
                    listener.CaseSkipped(skipResult);
                    classResult.Add(CaseResult.Skipped(skipResult.Case.Name, skipResult.Reason));
                }

                var caseExecutions = casesToExecute.Select(@case => new CaseExecution(@case)).ToArray();
                if (caseExecutions.Any())
                {
                    convention.ClassExecution.OrderCases(caseExecutions);

                    var classExecution = new ClassExecution(executionPlan, testClass, caseExecutions);
                    executionPlan.Execute(classExecution);

                    foreach (var caseExecution in caseExecutions)
                    {
                        if (caseExecution.Exceptions.Any())
                        {
                            var failResult = new FailResult(caseExecution, convention.HideExceptionDetails);
                            listener.CaseFailed(failResult);
                            classResult.Add(CaseResult.Failed(failResult.Case.Name, failResult.Duration, failResult.ExceptionSummary));
                        }
                        else
                        {
                            var passResult = new PassResult(caseExecution);
                            listener.CasePassed(passResult);
                            classResult.Add(CaseResult.Passed(passResult.Case.Name, passResult.Duration));
                        }
                    }

                }

                conventionResult.Add(classResult);
            }

            return conventionResult;
        }
コード例 #19
0
ファイル: ExecutionPlanTests.cs プロジェクト: samieze/aMuSE
        void test_sampleA_NoSelfForwarding()
        {
            ExecutionPlan executionPlan = new ExecutionPlan(new InputSamples().sampleA);

            foreach (var nodeDict in executionPlan.forwardRulesByNodeName)
            {
                foreach (var ruleItem in nodeDict.Value)
                {
                    Assert.DoesNotContain(nodeDict.Key, ruleItem.Value.destinations);
                }
            }
        }
コード例 #20
0
        public void Lift_MustThrowException_WhenFirstRequestNotSummonWithDirectionAndNoExecutionPlanComputed()
        {
            FloorConfiguration floorConfig = new FloorConfiguration(3, 0, 15);
            IExecutionPlan     plan        = new ExecutionPlan();
            ILift lift = new Lift(floorConfig, plan);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                new SummonInformation(floorConfig.CurrentFloor + 1, TravelDirection.None)
            };

            Assert.Throws <ArgumentException>(() => lift.ProcessRequests(requests));
        }
コード例 #21
0
        public void DirectoryProperties_ReturnsSuppliedDirectoryValues(string directory)
        {
            var executables = new List <ProcessExecutable>()
            {
                new ProcessExecutable(new Mock <IExecutable>().Object, new ExecutableConfiguration("type", 30, null))
            };

            var executionPlan = new ExecutionPlan(executables, directory, directory);

            Assert.Equal(directory, executionPlan.IntegrationDirectory);
            Assert.Equal(directory, executionPlan.ExecutablesDirectory);
        }
コード例 #22
0
        /// <summary>
        /// Looks for an ExecutionPlan to cover the Property in the given PropertyOwnership relation using the Properties this PropertyManager.
        /// </summary>
        /// <param name="propertyOwnershipToCover">The PropertyOwnership to which it is wanted to increase the value.</param>
        /// <param name="remainingValueToCover">The amount of value that is desired to increase with the obtained ExecutionPlan</param>
        /// <param name="executer">The MapElement that will execute the ExecutionPlan</param>
        /// <returns></returns>
        public ExecutionPlan GetExecutionPlanToCover(PropertyOwnership propertyOwnershipToCover, float remainingValueToCover, MapElement executer)
        {
            MapElement target = propertyOwnershipToCover.owner;

            // Debug.Log($" >>> Searching for an execution plan to cover '{remainingValueToCover}' of '{propertyOwnershipToCover.property}' owned by '{propertyOwnershipToCover.owner}' executed by '{executer}'.\n");

            foreach (PropertyOwnership ownedProperty in propertyOwnerships)
            {
                foreach (MapEvent mapEvent in ownedProperty.property.mapEvents)
                {
                    // Debug.Log($" >>> In '{ownedProperty.owner}', checking if mapEvent '{mapEvent}' in property '{ownedProperty.property}' can cover {remainingValueToCover} missing of the property '{propertyOwnershipToCover.property}'.\nTarget: {target}, Executer: {executer}, EventOwner still unknown.\n");
                    if (!mapEvent.executerMustOwnProperty || (mapEvent.executerMustOwnProperty && ownedProperty.owner == executer))
                    {
                        MapElement    eventOwner    = ownedProperty.owner;
                        ExecutionPlan executionPlan = new ExecutionPlan(mapEvent, executer, target, eventOwner, ownedProperty.property);
                        executionPlan.SetExecutionTimesToCover(propertyOwnershipToCover, remainingValueToCover);
                        int executionsToCover = executionPlan.executionTimes;
                        if (executionsToCover < 0) // The executionPlan can not cover the property
                        {
                            continue;
                        }

                        Dictionary <PropertyOwnership, float> mapEventRequirementsNotMet = mapEvent.GetRequirementsNotMet(ownedProperty.property, executer, target, owner, executionPlan.executionTimes);

                        if (mapEvent.tryToCoverRequirementsIfNotMet || (!mapEvent.tryToCoverRequirementsIfNotMet && mapEventRequirementsNotMet.IsNullOrEmpty()))
                        {
                            // If reached here, the mapEvent can be executed - Now choose if it is the appropriate one
                            // Debug.Log($"   > The mapEvent '{mapEvent}' can be executed ({mapEventRequirementsNotMet.Count} requirements must be covered before):\n    - {mapEventRequirementsNotMet.ToStringAllElements("\n    - ")}\n");

                            if (mapEvent.ConsequencesCover(propertyOwnershipToCover, target, executer, eventOwner, ownedProperty.property))
                            {
                                Debug.Log($" ● Found Execution Plan: {executionPlan}\n");
                                return(executionPlan);
                            }
                        }
                    }
                    else
                    {
                        // Debug.Log($"    The executer ({executer}) must own the property '{currentOwnedProperty.property}' to execute '{mapEvent}' but it does not. MapEvent owned by '{currentOwnedProperty.ownerMapElement}'.\n");
                        if (mapEvent.ConsequencesCover(propertyOwnershipToCover, target, executer, executer, ownedProperty.property))
                        {
                            ExecutionPlan executionPlan = new ExecutionPlan(mapEvent, executer, target, executer, ownedProperty.property);
                            executionPlan.SetExecutionTimesToCover(propertyOwnershipToCover, remainingValueToCover);
                            Debug.Log($" ● Found 'forced' Execution Plan: {executionPlan}\n");
                            return(executionPlan);
                        }
                    }
                }
            }

            return(null);
        }
コード例 #23
0
        public void BatchExecutionPlanValidTest()
        {
            // If I have an executed batch which has an execution plan
            Batch b = Common.GetExecutedBatchWithExecutionPlan();

            // ... And I ask for a valid execution plan
            ExecutionPlan plan = b.GetExecutionPlan(0).Result;

            // Then:
            // ... I should get the execution plan back
            Assert.Equal("xml", plan.Format);
            Assert.Contains("Execution Plan", plan.Content);
        }
コード例 #24
0
 protected override void BeginProcessing()
 {
     ExecutionPlan.DisposeHighlighers();
     ExecutionPlan.Init();
     HighlighterGeneration = 0;
     if (0 != MaxControlsHighlighted)
     {
         ExecutionPlan.DecreaseMaxCount(
             // UIAutomation.ExecutionPlan.DecreaseMaxCount(
             MaxControlsHighlighted);
     }
     Preferences.ShowExecutionPlan = true;
 }
コード例 #25
0
        public void ExecutionPlan_MultiDependency_Success()
        {
            // A. Setup
            ExecutionPlan executionPlan = new ExecutionPlan();
            CISession     ciSession     = new CISession();

            const string stage_01 = "st01";
            const string stage_02 = "st02";
            const string stage_03 = "st03";
            const string stage_04 = "st04";


            // B. Build some Build Stages to test with
            testStageClass stage01 = new testStageClass(stage_01, ciSession);
            testStageClass stage02 = new testStageClass(stage_02, ciSession);
            testStageClass stage03 = new testStageClass(stage_03, ciSession);
            testStageClass stage04 = new testStageClass(stage_04, ciSession);

            // Setup predecessors
            stage02.AddPredecessor(stage_01);
            stage03.AddPredecessor(stage_02);
            stage04.AddPredecessor(stage_02);
            stage04.AddPredecessor(stage_03);


            // B3 - Add to Execution plan
            executionPlan.AddKnownStage(stage01);
            executionPlan.AddKnownStage(stage02);
            executionPlan.AddKnownStage(stage03);
            executionPlan.AddKnownStage(stage04);


            // Test
            //Should be 2 steps in the plan and known stages
            executionPlan.BuildExecutionPlan(stage_04);

            // Validate
            Assert.AreEqual(4, executionPlan.KnownStages.Count, "A10: ");
            Assert.AreEqual(4, executionPlan.Plan.Count, "A20: ");

            // Validate the plan sequence
            LinkedListNode <BuildStage> node = executionPlan.Plan.First;

            Assert.AreEqual(stage01, node.Value, "A30:");
            node = node.Next;
            Assert.AreEqual(stage02, node.Value, "A40:");
            node = node.Next;
            Assert.AreEqual(stage03, node.Value, "A50:");
            node = node.Next;
            Assert.AreEqual(stage04, node.Value, "A60:");
        }
コード例 #26
0
        public override void Calculate()
        {
            // TODO: cancel, pause, retry , resume...

            var currentPlans = JobRepository.ActiveJobs(); //TODO: check already running task before planning next.
            var waiting      = JobRepository.WaitingJobs().OrderBy(j => j.DueDate).GetEnumerator();

            if (!waiting.MoveNext())
            {
                return;
            }
            foreach (var freePlugin in Plugins.Where(p => !p.Busy && p.PluginType == DummyLogoPP.Type))
            {
                var tcPlugin = Plugins.First(p => p.PluginType == DummyTCOnly.Type);
                var et1      = new ExecutionTask
                {
                    From = new Essence(waiting.Current.Source),
                    To   = new Essence(waiting.Current.Source)
                    {
                        Flags = waiting.Current.Destination.Flags, Files = null
                    },
                    PluginUrn = freePlugin.Urn
                };
                var et2 = new ExecutionTask
                {
                    From      = new Essence(et1.To),
                    To        = new Essence(waiting.Current.Destination),
                    PluginUrn = tcPlugin.Urn
                };
                if (!freePlugin.CheckAndEstimate(et1))
                {
                    continue;
                }
                if (!tcPlugin.CheckAndEstimate(et2))
                {
                    continue;
                }
                var ep = new ExecutionPlan {
                    Tasks = new List <ExecutionTask> {
                        et1, et2
                    }
                };
                waiting.Current.Plan = ep;
                JobRepository.Update(waiting.Current);
                if (!waiting.MoveNext())
                {
                    break;
                }
            }
        }
コード例 #27
0
        private void PlayAnimation(string name, int duration, bool loop = false)
        {
            if (_scheduledBackground != null)
            {
                _scheduledBackground.Dispose();
                _scheduledBackground = null;
            }

            ChromaAnimationAPI.PlayAnimationName(ANIMATION_PATH + "/" + name + ".chroma", loop);

            if (duration > 0)
            {
                _scheduledBackground = ExecutionPlan.Delay(duration, PlayBackground);
            }
        }
コード例 #28
0
ファイル: TestScriptService.cs プロジェクト: heran/DekiWiki
 public void Execute(ExecutionPlan plan) {
     var service = DreamTestHelper.CreateService(
         _hostinfo,
         "sid://mindtouch.com/2007/12/dekiscript",
         "dekiscript",
         new XDoc("config").Elem("manifest", _manifestUri)
     );
     foreach(var functionName in _manifest["function/name"]) {
         var name = functionName.AsText;
         _tester.Runtime.RegisterFunction(name, service.AtLocalHost.At(name));
     }
     try {
         var expr = _tester.Parse(plan.Expr);
         var env = _tester.Runtime.CreateEnv();
         env.Vars.Add(DekiScriptEnv.SAFEMODE, DekiScriptExpression.Constant(plan.Safe));
         DekiScriptExpression result = _tester.Runtime.Evaluate(expr, plan.Safe ? DekiScriptEvalMode.EvaluateSafeMode : DekiScriptEvalMode.Evaluate, env);
         if(plan.TypedVerification != null) {
             Assert.AreEqual(plan.ExpectedType,result.GetType());
             plan.TypedVerification(result);
         } else if(plan.DocVerification != null) {
             if(!(result is DekiScriptXml)) {
                 Assert.Fail(string.Format("return type was '{0}' not DekiScriptXml", result.GetType()));
             }
             var doc = ((DekiScriptXml)result).Value;
             plan.DocVerification(doc);
         } else if(plan.StringVerification != null) {
             string value;
             if(result is DekiScriptString) {
                 value = ((DekiScriptString)result).Value;
             } else if(result is DekiScriptXml) {
                 value = ((DekiScriptXml)result).Value.ToString();
             } else {
                 value = result.ToString();
             }
             plan.StringVerification(value, result.GetType());
         } else {
             Assert.Fail("Execution completed without exception");
         }
     } catch(Exception e) {
         if(plan.ExceptionVerification != null) {
             plan.ExceptionVerification(e);
         } else {
             throw;
         }
     } finally {
         service.WithPrivateKey().AtLocalHost.Delete();
     }
 }
コード例 #29
0
        public void ExecutionPlanValid()
        {
            // Setup:
            // ... I have a batch that has been executed with a execution plan
            Batch b = Common.GetExecutedBatchWithExecutionPlan();

            // If:
            // ... I have a result set and I ask for a valid execution plan
            ResultSet     planResultSet = b.ResultSets.First();
            ExecutionPlan plan          = planResultSet.GetExecutionPlan().Result;

            // Then:
            // ... I should get the execution plan back
            Assert.Equal("xml", plan.Format);
            Assert.Contains("Execution Plan", plan.Content);
        }
コード例 #30
0
ファイル: DCEPNode.cs プロジェクト: samieze/aMuSE
 public DCEPNode(NodeName name, string[] inputlines, DCEPSettings settings)
 {
     TAG = "[" + name + "] ";
     Console.WriteLine(TAG + "DCEPNode Constructor called.");
     state = NodeExecutionState.WaitForStart;
     receivedEventCount      = 0;
     sentReadyToStartMessage = false;
     nodeName            = name;
     externalEventQueue  = new SerializableQueue <AbstractEvent>();
     internalEventQueue  = new SerializableQueue <AbstractEvent>();
     controlMessageQueue = new SerializableQueue <DCEPControlMessage>();
     queryProcessors     = new List <QueryProcessor>();
     this.settings       = settings;
     executionPlan       = new ExecutionPlan(inputlines);
     benchmarkMeter      = new BenchmarkMeter(settings, nodeName);
     createQueryProcessors(executionPlan.queriesByNodeName[nodeName]);
 }
コード例 #31
0
        private void TryExecute(IDbConnection connection, ExecutionPlan plan, StringBuilder query, IDbTransaction transaction, ref IDbCommand cmd,
                                ref int nbParams, ref bool cancel)
        {
            const int maxBatchSizeKo = 65536;
            const int maxParam       = 1900;

            if (nbParams <= maxParam && query.Length <= maxBatchSizeKo)
            {
                return;
            }

            Execute(plan, query, transaction, cmd, ref cancel);

            nbParams = 0;
            query.Clear();
            cmd = connection.CreateCommand();
        }
コード例 #32
0
        public void Lift_CreateExecutionPlanWith2Values_WhenParkedOnLowerFloorAndSummonToGoUp()
        {
            FloorConfiguration floorConfig     = new FloorConfiguration(0, 0, 15);
            IExecutionPlan     plan            = new ExecutionPlan();
            ILift                     lift     = new Lift(floorConfig, plan);
            SummonInformation         summon   = new SummonInformation(1, TravelDirection.Up);
            SummonInformation         request  = new SummonInformation(5, TravelDirection.None, summon);
            IList <SummonInformation> requests = new List <SummonInformation>()
            {
                summon,
                request
            };

            var executionPlan = lift.ProcessRequests(requests);

            var planResult = executionPlan.GetFloorVisitationPlan();

            Assert.Equal(2, planResult.Count());
        }
コード例 #33
0
ファイル: ExecuteCasesTests.cs プロジェクト: ridecar2/fixie
        public void ShouldPerformCaseExecutionBehaviorForAllGivenCases()
        {
            var caseA = new Case(testClass.GetInstanceMethod("Pass"));
            var caseB = new Case(testClass.GetInstanceMethod("Fail"));

            var caseExecutions = new[]
            {
                new CaseExecution(caseA),
                new CaseExecution(caseB)
            };

            var executeCases = new ExecuteCases();
            var executionPlan = new ExecutionPlan(convention);
            var instanceExecution = new InstanceExecution(executionPlan, testClass, new SampleTestClass(), caseExecutions);
            executeCases.Execute(instanceExecution);

            caseExecutions[0].Exceptions.Any().ShouldBeFalse();
            caseExecutions[1].Exceptions.Single().Message.ShouldEqual("'Fail' failed!");
            log.ShouldEqual("Pass", "Fail");
        }