Beispiel #1
0
        public void BuildIndexes_creates_consolidated_index_for_each_named_and_unamed_index()
        {
            var columns = new[]
            {
                CreateColumn("tut1", new IndexAttribute("pong1", 0), new IndexAttribute("pong2", 4)),
                CreateColumn("tut2"),
                CreateColumn("tut3", new IndexAttribute("pong1", 1), new IndexAttribute("pong3"), new IndexAttribute()),
                CreateColumn("tut4", new IndexAttribute("pong1", 2), new IndexAttribute("pong2", 1)),
                CreateColumn("tut5", new IndexAttribute())
            };

            var indexes = ConsolidatedIndex.BuildIndexes("raS", columns).ToArray();

            Assert.Equal(5, indexes.Length);

            var index = indexes.Single(i => i.Index.Name == "pong1");

            Assert.Equal(new[] { "tut1", "tut3", "tut4" }, index.Columns);

            index = indexes.Single(i => i.Index.Name == "pong2");
            Assert.Equal(new[] { "tut4", "tut1" }, index.Columns);

            index = indexes.Single(i => i.Index.Name == "pong3");
            Assert.Equal(new[] { "tut3" }, index.Columns);

            var unnamedIndexes = indexes.Where(i => i.Index.Name == null).ToArray();

            Assert.Equal(2, unnamedIndexes.Length);
            Assert.Equal(new[] { "tut3", "tut5" }, unnamedIndexes.Select(i => i.Columns.Single()).OrderBy(n => n));
        }