예제 #1
0
        public void Execute_StandardRsColumnNameAndVariableFirstArg_CorrectExtension()
        {
            var args     = new ObjectsResultSetResolverArgs(new[] { new object[] { "Alpha", 1, 2 }, new object[] { "Beta", 3, 2 }, new object[] { "Gamma", 5, 7 } });
            var resolver = new ObjectsResultSetResolver(args);
            var rs       = resolver.Execute();

            rs.Columns[0].ColumnName = "a";
            rs.Columns[1].ColumnName = "b";
            rs.Columns[2].ColumnName = "c";

            var extender = new NativeExtendEngine(
                new ServiceLocator(),
                new Context(new Dictionary <string, ITestVariable> {
                { "myVar", new GlobalVariable(new LiteralScalarResolver <string>("foo")) }
            }),
                new ColumnNameIdentifier("d"),
                "@myVar | text-to-first-chars(#1) | text-to-upper"
                );
            var newRs = extender.Execute(rs);

            Assert.That(newRs.Columns.Count, Is.EqualTo(4));
            Assert.That(newRs.Columns[3].ColumnName, Is.EqualTo("d"));
            Assert.That(newRs.Rows[0][3], Is.EqualTo("F"));
            Assert.That(newRs.Rows[1][3], Is.EqualTo("FOO"));
            Assert.That(newRs.Rows[2][3], Is.EqualTo("FOO"));
        }
예제 #2
0
        public void Execute_ManyTimes_Performances(int count)
        {
            var rows = new List <object[]>();

            for (int i = 0; i < count; i++)
            {
                rows.Add(new object[] { i, i + 1 });
            }

            var args     = new ObjectsResultSetResolverArgs(rows.ToArray());
            var resolver = new ObjectsResultSetResolver(args);
            var rs       = resolver.Execute();

            rs.Columns[0].ColumnName = "a";
            rs.Columns[1].ColumnName = "b";

            var stopWatch = new Stopwatch();

            stopWatch.Start();
            var extender = new NativeExtendEngine(
                new ServiceLocator(),
                new Context(null),
                new ColumnNameIdentifier("c"),
                "[b] | numeric-to-multiply([a]) | numeric-to-add([a], [b])"
                );

            extender.Execute(rs);
            stopWatch.Stop();

            Assert.That(stopWatch.ElapsedMilliseconds, Is.LessThanOrEqualTo(5000));
        }
예제 #3
0
        public void Execute_StandardRsColumnOrdinal_CorrectExtension()
        {
            var args     = new ObjectsResultSetResolverArgs(new[] { new object[] { "Alpha", 1, 2 }, new object[] { "Beta", 3, 2 }, new object[] { "Gamma", 5, 7 } });
            var resolver = new ObjectsResultSetResolver(args);
            var rs       = resolver.Execute();

            var extender = new NativeExtendEngine(
                new ServiceLocator(),
                new Context(null),
                new ColumnOrdinalIdentifier(3),
                "#1 | numeric-to-multiply(#2)"
                );
            var newRs = extender.Execute(rs);

            Assert.That(newRs.Columns.Count, Is.EqualTo(4));
            Assert.That(newRs.Rows[0][3], Is.EqualTo(2));
            Assert.That(newRs.Rows[1][3], Is.EqualTo(6));
            Assert.That(newRs.Rows[2][3], Is.EqualTo(35));
        }
예제 #4
0
        public void Execute_StandardRsColumnName_CorrectExtension()
        {
            var args     = new ObjectsResultSetResolverArgs(new[] { new object[] { "Alpha", 1, 2 }, new object[] { "Beta", 3, 2 }, new object[] { "Gamma", 5, 7 } });
            var resolver = new ObjectsResultSetResolver(args);
            var rs       = resolver.Execute();

            rs.Columns[0].ColumnName = "a";
            rs.Columns[1].ColumnName = "b";
            rs.Columns[2].ColumnName = "c";

            var extender = new NativeExtendEngine(
                new ServiceLocator(),
                new Context(null),
                new ColumnNameIdentifier("d"),
                "[a] | text-to-first-chars([c]) | text-to-upper"
                );
            var newRs = extender.Execute(rs);

            Assert.That(newRs.Columns.Count, Is.EqualTo(4));
            Assert.That(newRs.Columns[3].ColumnName, Is.EqualTo("d"));
            Assert.That(newRs.Rows[0][3], Is.EqualTo("AL"));
            Assert.That(newRs.Rows[1][3], Is.EqualTo("BE"));
            Assert.That(newRs.Rows[2][3], Is.EqualTo("GAMMA"));
        }