예제 #1
0
        public virtual async ValueTask Execute(IExecutionContext executionContext, CancellationToken token)
        {
            if (executionContext is null)
            {
                throw new ArgumentNullException(nameof(executionContext));
            }

            var array = await ArrayEvaluator.EvaluateArray(executionContext, token).ConfigureAwait(false);

            for (var i = 0; i < array.Length; i++)
            {
                var instance = array[i];

                await ItemEvaluator.SetValue(instance, executionContext, token).ConfigureAwait(false);

                if (IndexEvaluator is not null)
                {
                    await IndexEvaluator.SetValue(new DefaultObject(i), executionContext, token).ConfigureAwait(false);
                }

                foreach (var execEvaluator in ActionEvaluatorList)
                {
                    await execEvaluator.Execute(executionContext, token).ConfigureAwait(false);
                }
            }
        }
예제 #2
0
        public void Execute_Duplicate_OneOccurence()
        {
            var resultSet = BuildDataTable(
                new List <List <object> >()
            {
                new List <object>()
                {
                    "a", "b", 120
                },
                new List <object>()
                {
                    "a", "b", 120
                },
                new List <object>()
                {
                    "a", "d", 150
                },
            });

            var finder = new IndexEvaluator();
            var result = finder.Execute(resultSet);

            Assert.That(result.Values.Count(), Is.EqualTo(1));
            Assert.That(result.Values.ElementAt(0).OccurenceCount, Is.EqualTo(2));
        }
예제 #3
0
        public void Execute_Duplicate_TwoOccurences()
        {
            var resultSet = BuildDataTable(
                new List <List <object> >()
            {
                new List <object>()
                {
                    "a", "b", 120
                },
                new List <object>()
                {
                    "a", "b", 120
                },
                new List <object>()
                {
                    "a", "b", 120
                },
            });

            var finder = new IndexEvaluator();
            var result = finder.Execute(resultSet);

            Assert.That(result.Values.Count(), Is.EqualTo(1));
            Assert.That(result.Values.ElementAt(0).OccurenceCount, Is.EqualTo(3));
            Assert.That(result.Values.ElementAt(0).Keys.Members, Has.Member("a"));
            Assert.That(result.Values.ElementAt(0).Keys.Members, Has.Member("b"));
            Assert.That(result.Values.ElementAt(0).Keys.Members, Has.Member("120"));
            Assert.That(result.Rows.Count(), Is.EqualTo(1));
            Assert.That(result.Rows.ElementAt(0).ItemArray, Has.Member(3));
            Assert.That(result.Rows.ElementAt(0).ItemArray, Has.Member("a"));
            Assert.That(result.Rows.ElementAt(0).ItemArray, Has.Member("b"));
            Assert.That(result.Rows.ElementAt(0).ItemArray, Has.Member("120"));
        }
        public override async ValueTask Execute(IExecutionContext executionContext, CancellationToken token)
        {
            var engine = executionContext.Engine();

            engine.EnterExecutionContext();

            try
            {
                ItemEvaluator.DeclareLocalVariable(executionContext);
                IndexEvaluator?.DeclareLocalVariable(executionContext);

                await base.Execute(executionContext, token).ConfigureAwait(false);
            }
            finally
            {
                engine.LeaveExecutionContext();
            }
        }
예제 #5
0
        public void Execute_Duplicate_False()
        {
            var resultSet = BuildDataTable(
                new List <List <object> >()
            {
                new List <object>()
                {
                    "a", "b", 120
                },
                new List <object>()
                {
                    "a", "b", 120
                },
                new List <object>()
                {
                    "a", "d", 150
                },
            });

            var finder = new IndexEvaluator();
            var result = finder.Execute(resultSet);

            Assert.That(result.AreUnique, Is.False);
        }