Пример #1
0
        public void Execute_SingleColumn_TwoGroups()
        {
            var args      = new ObjectsResultSetResolverArgs(new[] { new object[] { "alpha", 1 }, new object[] { "beta", 2 }, new object[] { "BETA", 3 }, new object[] { "alpha", 4 } });
            var resolver  = new ObjectsResultSetResolver(args);
            var rs        = resolver.Execute();
            var lowerCase = new SinglePredication(new TextLowerCase(false), new ColumnOrdinalIdentifier(0));
            var upperCase = new SinglePredication(new TextUpperCase(false), new ColumnOrdinalIdentifier(0));

            var grouping = new CaseGrouping(new IPredication[] { lowerCase, upperCase }, Context.None);

            var result = grouping.Execute(rs);

            Assert.That(result, Has.Count.EqualTo(2));
            Assert.That(result.ElementAt(0).Value.Rows, Has.Count.EqualTo(3));
            Assert.That(result.ElementAt(1).Value.Rows, Has.Count.EqualTo(1));
        }
Пример #2
0
        public void Execute_TwoColumns_ThreeGroups()
        {
            var args      = new ObjectsResultSetResolverArgs(new[] { new object[] { "alpha", "1", 10 }, new object[] { "ALPHA", "1", 20 }, new object[] { "beta", "2", 30 }, new object[] { "ALPHA", "2", 40 } });
            var resolver  = new ObjectsResultSetResolver(args);
            var rs        = resolver.Execute();
            var lowerCase = new SinglePredication(new TextLowerCase(false), new ColumnOrdinalIdentifier(0));
            var upperCase = new AndCombinationPredication(new List <IPredication>()
            {
                new SinglePredication(new TextUpperCase(false), new ColumnOrdinalIdentifier(0)),
                new SinglePredication(new TextEqual(false, new LiteralScalarResolver <string>("1")), new ColumnOrdinalIdentifier(1)),
            });

            var grouping = new CaseGrouping(new IPredication[] { lowerCase, upperCase }, Context.None);

            var result = grouping.Execute(rs);

            Assert.That(result, Has.Count.EqualTo(3));
            Assert.That(result.ElementAt(0).Value.Rows, Has.Count.EqualTo(2));
            Assert.That(result.ElementAt(1).Value.Rows, Has.Count.EqualTo(1));
            Assert.That(result.ElementAt(2).Value.Rows, Has.Count.EqualTo(1));
        }