Beispiel #1
0
        public void DistinctTest()
        {
            var node = new DistinctNode
            {
                Columns = { "value1" },
                Source  = new ConstantScanNode
                {
                    Values =
                    {
                        new Entity {
                            ["value1"] = new SqlInt32(1), ["value2"] = new SqlInt32(1)
                        },
                        new Entity {
                            ["value1"] = new SqlInt32(3), ["value2"] = new SqlInt32(2)
                        },
                        new Entity {
                            ["value1"] = new SqlInt32(1), ["value2"] = new SqlInt32(3)
                        }
                    },
                    Schema =
                    {
                        ["value1"] = typeof(SqlInt32),
                        ["value2"] = typeof(SqlInt32)
                    }
                }
            };

            var results = node.Execute(_dataSources, new StubOptions(), null, null)
                          .Select(e => e.GetAttributeValue <SqlInt32>("value1").Value)
                          .ToArray();

            CollectionAssert.AreEqual(new[] { 1, 3 }, results);
        }
Beispiel #2
0
        public void DistinctCaseInsensitiveTest()
        {
            var node = new DistinctNode
            {
                Columns = { "value1" },
                Source  = new ConstantScanNode
                {
                    Values =
                    {
                        new Entity {
                            ["value1"] = new SqlString("hello", CultureInfo.CurrentCulture.LCID, SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreNonSpace), ["value2"] = new SqlInt32(1)
                        },
                        new Entity {
                            ["value1"] = new SqlString("world", CultureInfo.CurrentCulture.LCID, SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreNonSpace), ["value2"] = new SqlInt32(2)
                        },
                        new Entity {
                            ["value1"] = new SqlString("Hello", CultureInfo.CurrentCulture.LCID, SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreNonSpace), ["value2"] = new SqlInt32(3)
                        }
                    },
                    Schema =
                    {
                        ["value1"] = typeof(SqlString),
                        ["value2"] = typeof(SqlInt32)
                    }
                }
            };

            var results = node.Execute(_dataSources, new StubOptions(), null, null)
                          .Select(e => e.GetAttributeValue <SqlString>("value1").Value)
                          .ToArray();

            CollectionAssert.AreEqual(new[] { "hello", "world" }, results);
        }
Beispiel #3
0
 public DistinctTable(DistinctNode node, Program program) : base(node, program)
 {
 }