public void TestADOTabularCSDLVisitTwice()
        {
            //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);

            MetaDataVisitorCSDL v  = new MetaDataVisitorCSDL(connection);
            ADOTabularDatabase  db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*");
            ADOTabularModel     m  = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", "");

            using (System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\csdl.xml"))
            {
                var tabs = new ADOTabularTableCollection(connection, m);

                v.GenerateTablesFromXmlReader(tabs, xr);

                Assert.AreEqual(4, tabs.Count);
                Assert.AreEqual(8, tabs["Sales"].Columns.Count());
                Assert.AreEqual(0, tabs["Sales"].Columns[2].DistinctValues);
            }

            m = new ADOTabularModel(connection, db, "Test2", "Test2", "Test2 Description", "");
            using (System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\csdl.xml"))
            {
                var tabs = new ADOTabularTableCollection(connection, m);

                v.GenerateTablesFromXmlReader(tabs, xr);

                Assert.AreEqual(4, tabs.Count);
                Assert.AreEqual(8, tabs["Sales"].Columns.Count());
                Assert.AreEqual(0, tabs["Sales"].Columns[2].DistinctValues);
            }
        }
Beispiel #2
0
        public void TestPowerBITomModel_CSDL_2_5()
        {
            //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);

            //IADOTabularConnection c = new Mock<IADOTabularConnection>().Object;
            MetaDataVisitorCSDL v  = new MetaDataVisitorCSDL(connection);
            ADOTabularDatabase  db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*");
            ADOTabularModel     m  = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\csdl_2_5.xml");
            var tabs = new ADOTabularTableCollection(connection, m);

            v.GenerateTablesFromXmlReader(tabs, xr);

            Assert.IsNotNull(m.TOMModel);
            Assert.AreEqual(tabs.Count, m.TOMModel.Tables.Count, "Table Counts are equal");
            Assert.AreEqual(tabs["Product"].Columns.Count, m.TOMModel.Tables["Product"].Columns.Count, "Product column counts are equal");
            Assert.AreEqual(tabs["Sales"].Relationships.Count, m.TOMModel.Relationships.Count(r => r.FromTable.Name == "Sales"), "Sales table relationships are equal");
            Assert.AreEqual(2, m.TOMModel.Tables["Sales"].Measures.Count, "Sales table measure counts are equal");

            Assert.AreEqual(8, m.TOMModel.Relationships.Count, "Total Relationships");
            Assert.AreEqual(4, m.TOMModel.Relationships.Count(r => r.FromTable.Name == "Sales"), "4 relationships FROM sales table");
            Assert.AreEqual(2, m.TOMModel.Relationships.Count(r => r.FromTable.Name == "Bugets"), "2 relationships FROM budgets table");
            Assert.AreEqual(1, m.TOMModel.Relationships.Count(r => !r.IsActive), "There should be 1 inactive relationship");
            Assert.AreEqual(3, m.TOMModel.Relationships.Count(r => r.CrossFilteringBehavior == CrossFilteringBehavior.BothDirections), "3 Bi-Di relationships");
            Assert.AreEqual(1, m.TOMModel.Relationships.Count(r => r.CrossFilteringBehavior == CrossFilteringBehavior.BothDirections && !r.IsActive), "1 inactive Bi-Di relationships");
        }
        public void TestCSDLRelationships()
        {
            //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);

            MetaDataVisitorCSDL v  = new MetaDataVisitorCSDL(connection);
            ADOTabularDatabase  db = GetTestDB();
            ADOTabularModel     m  = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\RelationshipCsdl.xml");
            var tabs = new ADOTabularTableCollection(connection, m);

            v.GenerateTablesFromXmlReader(tabs, xr);

            Assert.AreEqual(6, tabs.Count, "Table count is correct");
            Assert.AreEqual(1, tabs["Customer"].Relationships.Count, "Customer Table has incorrect relationship count");
            Assert.AreEqual(0, tabs["Accounts"].Relationships.Count, "Accounts Table has incorrect relationship count");
            Assert.AreEqual(1, tabs["Customer Geography"].Relationships.Count, "Customer Geography Table has incorrect relationship count");
            Assert.AreEqual("Both", tabs["Customer Geography"].Relationships[0].CrossFilterDirection, "Customer Geography Table has a Both crossfilter relationship");
            Assert.AreEqual(1, tabs["Geography Population"].Relationships.Count, "Geography Table has incorrect relationship count");
            Assert.AreEqual(2, tabs["Customer Accounts"].Relationships.Count, "Customer Accounts Table has incorrect relationship count");
            Assert.AreEqual("Both", tabs["Customer Accounts"].Relationships[0].CrossFilterDirection, "Customer Accounts Table has a Both crossfilter on relationship 0");
            Assert.AreEqual("", tabs["Customer Accounts"].Relationships[1].CrossFilterDirection, "Customer Accounts Table does not have a Both crossfilter on relationship 1");

            var tabCust           = tabs["Customer"];
            var relCustToCustGeog = tabCust.Relationships[0];

            //var col = tabCust.Columns.GetByPropertyRef("Customer_Geography_ID2");

            Assert.AreEqual("", relCustToCustGeog.CrossFilterDirection);
            Assert.AreEqual("Customer_Geography_ID2", relCustToCustGeog.FromColumn, "Incorrect from column");
            Assert.AreEqual("*", relCustToCustGeog.FromColumnMultiplicity);
            Assert.AreEqual("Customer_Geography_ID", relCustToCustGeog.ToColumn, "Incorrect to column");
            Assert.AreEqual("0..1", relCustToCustGeog.ToColumnMultiplicity);
        }
        public void TestPowerBICSDLVisitor()
        {
            ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);
            MetaDataVisitorCSDL  v = new MetaDataVisitorCSDL(c);
            ADOTabularModel      m = new ADOTabularModel(c, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\powerbi-csdl.xml");
            var tabs = new ADOTabularTableCollection(c, m);

            v.GenerateTablesFromXmlReader(tabs, xr);

            Assert.AreEqual(13, tabs.Count, "Wrong number of tables in database");
            Assert.AreEqual(2, tabs["ProductCategory"].Columns.Count(), "Wrong Column Count in ProductCategory");
            Assert.AreEqual(8, tabs["ProductCategory"].Columns["ProductCategory"].DistinctValues);
        }
        public void TestADOTabularCSDLVisitor()
        {
            ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);
            MetaDataVisitorCSDL  v = new MetaDataVisitorCSDL(c);
            ADOTabularModel      m = new ADOTabularModel(c, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\csdl.xml");
            var tabs = new ADOTabularTableCollection(c, m);

            v.GenerateTablesFromXmlReader(tabs, xr);

            Assert.AreEqual(4, tabs.Count);
            Assert.AreEqual(8, tabs["Sales"].Columns.Count());
            Assert.AreEqual(0, tabs["Sales"].Columns[2].DistinctValues);
        }
        public void TestPowerBIDatabaseCulture()
        {
            MetaDataVisitorCSDL v  = new MetaDataVisitorCSDL(connection);
            ADOTabularDatabase  db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*");
            ADOTabularModel     m  = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\powerbi-csdl.xml");
            var tabs = new ADOTabularTableCollection(connection, m);

            Assert.AreEqual(string.Empty, db.Culture);

            v.GenerateTablesFromXmlReader(tabs, xr);

            Assert.AreEqual("en-US", db.Culture);
        }
        public void TestADOTabularLargeCSDLVisitor()
        {
            ADOTabularConnection connection = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);
            MetaDataVisitorCSDL  visitor    = new MetaDataVisitorCSDL(connection);
            ADOTabularModel      model      = new ADOTabularModel(connection, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\mtm_csdl.xml");
            var tabs = new ADOTabularTableCollection(connection, model);

            visitor.GenerateTablesFromXmlReader(tabs, xr);

            Assert.AreEqual(110, tabs.Count);
            Assert.AreEqual(190, tabs["Orders"].Columns.Where(c => c.ColumnType == ADOTabularColumnType.Column).Count());
            Assert.AreEqual(347, tabs["Orders"].Columns.Where(c => c.ColumnType == ADOTabularColumnType.Measure).Count());
        }
        public void TestCSDLTablesWithSpaces()
        {
            ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);
            MetaDataVisitorCSDL  v = new MetaDataVisitorCSDL(c);
            ADOTabularModel      m = new ADOTabularModel(c, "Test", "Test Caption", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\advwrkscsdl.xml");
            var tabs = new ADOTabularTableCollection(c, m);

            v.GenerateTablesFromXmlReader(tabs, xr);
            var cmpyTab = tabs["Sales Quota"];


            Assert.AreEqual("Sales Quota", cmpyTab.Caption, "Table Name is translated");
        }
Beispiel #9
0
        public void TestADOTabularCSDLVisitorMeasureDescriptions()
        {
            //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);

            MetaDataVisitorCSDL v  = new MetaDataVisitorCSDL(connection);
            ADOTabularDatabase  db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*");
            ADOTabularModel     m  = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\csdl.xml");
            var tabs = new ADOTabularTableCollection(connection, m);

            v.GenerateTablesFromXmlReader(tabs, xr);

            var measure = tabs["Sales"].Columns["Sector Sales"];

            Assert.AreEqual("Sector Sales Description", measure.Description);
        }
Beispiel #10
0
        public void TestCSDLColumnTranslations()
        {
            //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);

            MetaDataVisitorCSDL v = new MetaDataVisitorCSDL(connection);
            ADOTabularModel     m = new ADOTabularModel(connection, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\advwrkscsdl.xml");
            var tabs = new ADOTabularTableCollection(connection, m);

            v.GenerateTablesFromXmlReader(tabs, xr);
            var cmpyTab = tabs["Reseller"];
            var cmpyCol = cmpyTab.Columns["Reseller Name"];

            Assert.AreEqual("Reseller Cap", cmpyTab.Caption, "Table Name is translated");
            Assert.AreEqual("Reseller Name Cap", cmpyCol.Caption, "Column Name is translated");
        }
Beispiel #11
0
        public void TestCSDLMarkAsDateTable()
        {
            //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);
            MetaDataVisitorCSDL v  = new MetaDataVisitorCSDL(connection);
            ADOTabularDatabase  db = GetTestDB();
            ADOTabularModel     m  = new ADOTabularModel(connection, db, "Test", "Test Caption", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\advwrkscsdl.xml");
            var tabs = new ADOTabularTableCollection(connection, m);

            v.GenerateTablesFromXmlReader(tabs, xr);
            var cmpyTab = tabs["Date"];


            Assert.AreEqual(true, cmpyTab.IsDateTable, "'Date' table is marked as date table");
            Assert.AreEqual(false, tabs["Customer"].IsDateTable, "'Date' table is marked as date table");
        }
        public void TestInvalidCSDLKPIs()
        {
            ADOTabularConnection c = new ADOTabularConnection(ConnectionString + ";Initial Catalog=AW Internet Sales Tabular Model 2014", AdomdType.AnalysisServices);

            c.Open();
            MetaDataVisitorCSDL v = new MetaDataVisitorCSDL(c);
            ADOTabularModel     m = new ADOTabularModel(c, "Test", "Test Caption", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\aw_internetsales_2014_csdl.xml");
            var tabs = new ADOTabularTableCollection(c, m);

            v.GenerateTablesFromXmlReader(tabs, xr);
            var cmpyTab = tabs["Internet Sales"];


            Assert.AreEqual("Internet Sales", cmpyTab.Caption, "Table Name is translated");
        }
        public void TestPowerBIModelCapabilities()
        {
            //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);

            //IADOTabularConnection c = new Mock<IADOTabularConnection>().Object;
            MetaDataVisitorCSDL v  = new MetaDataVisitorCSDL(connection);
            ADOTabularDatabase  db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*");
            ADOTabularModel     m  = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\powerbi-csdl.xml");
            var tabs = new ADOTabularTableCollection(connection, m);

            v.GenerateTablesFromXmlReader(tabs, xr);

            Assert.AreEqual(false, m.Capabilities.DAXFunctions.SubstituteWithIndex);
            Assert.AreEqual(true, m.Capabilities.DAXFunctions.SummarizeColumns);
        }
Beispiel #14
0
        public void TestPowerBICSDLVisitor()
        {
            //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);

            //IADOTabularConnection c = new Mock<IADOTabularConnection>().Object;
            MetaDataVisitorCSDL v  = new MetaDataVisitorCSDL(connection);
            ADOTabularDatabase  db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*");
            ADOTabularModel     m  = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\powerbi-csdl.xml");
            var tabs = new ADOTabularTableCollection(connection, m);

            v.GenerateTablesFromXmlReader(tabs, xr);

            Assert.AreEqual(13, tabs.Count, "Wrong number of tables in database");
            Assert.AreEqual(2, tabs["ProductCategory"].Columns.Count(), "Wrong Column Count in ProductCategory");
            Assert.AreEqual(8, tabs["ProductCategory"].Columns["ProductCategory"].DistinctValues);
        }
Beispiel #15
0
        public void TestPowerBIVariationsVisitor()
        {
            //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);

            //IADOTabularConnection c = new Mock<IADOTabularConnection>().Object;
            MetaDataVisitorCSDL v = new MetaDataVisitorCSDL(connection);
            ADOTabularModel     m = new ADOTabularModel(connection, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\powerbi-csdl.xml");
            var tabs = new ADOTabularTableCollection(connection, m);

            v.GenerateTablesFromXmlReader(tabs, xr);
            var promoTable = tabs["Promotion"];

            Assert.IsNotNull(promoTable);
            Assert.AreEqual(0, promoTable.Columns["PromotionName"].Variations.Count);
            Assert.AreEqual(1, promoTable.Columns["StartDate"].Variations.Count);
        }
Beispiel #16
0
        public void TestCSDLDisplayFolders()
        {
            MetaDataVisitorCSDL v = new MetaDataVisitorCSDL(connection);
            ADOTabularModel     m = new ADOTabularModel(connection, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\AdvWrksFoldersCsdl.xml");
            var tabs = new ADOTabularTableCollection(connection, m);

            v.GenerateTablesFromXmlReader(tabs, xr);
            var cmpyTab = tabs["Internet Sales"];
            var cmpyCol = cmpyTab.Columns["Internet Current Quarter Sales"];

            var cmpyCol2 = cmpyTab.Columns["Internet Current Quarter Margin"];

            Assert.AreEqual("Internet Sales", cmpyTab.Caption, "Table Name is correct");
            Assert.AreEqual("QTD Folder", cmpyTab.FolderItems[0].Name);
            Assert.AreEqual(8, ((IADOTabularFolderReference)cmpyTab.FolderItems[0]).FolderItems.Count);
        }
Beispiel #17
0
        public void TestCSDLDisplayFolders()
        {
            ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);
            MetaDataVisitorCSDL  v = new MetaDataVisitorCSDL(c);
            ADOTabularModel      m = new ADOTabularModel(c, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\AdvWrksFoldersCsdl.xml");
            var tabs = new ADOTabularTableCollection(c, m);

            v.GenerateTablesFromXmlReader(tabs, xr);
            var cmpyTab = tabs["Internet Sales"];
            var cmpyCol = cmpyTab.Columns["Internet Current Quarter Sales"];

            var cmpyCol2 = cmpyTab.Columns["Internet Current Quarter Margin"];

            Assert.AreEqual("Internet Sales", cmpyTab.Caption, "Table Name is correct");
            Assert.AreEqual("QTD Folder", cmpyCol2.DisplayFolder, "Column has display folder");
            Assert.AreEqual("QTD Folder", cmpyCol.DisplayFolder, "Column has display folder");
        }
Beispiel #18
0
        public void TestADOTabularCSDLVisitorMeasures()
        {
            //var c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);

            var v    = new MetaDataVisitorCSDL(connection);
            var m    = new ADOTabularModel(connection, "AdventureWorks", "AdventureWorks", "Test AdventureWorks", "");
            var tabs = new ADOTabularTableCollection(connection, m);

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\AdvWrks.xml");
            //ADOTabularModel m = new ADOTabularModel(connection, "Test", "Test Caption", "Test Description", "");
            //var tabs = new ADOTabularTableCollection(connection, m);
            v.GenerateTablesFromXmlReader(tabs, xr);


            foreach (var table in tabs)
            {
                var measures = table.Measures;
            }
        }
Beispiel #19
0
        public void TestPowerBITomModel_CSDL_2_0()
        {
            //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);

            //IADOTabularConnection c = new Mock<IADOTabularConnection>().Object;
            MetaDataVisitorCSDL v  = new MetaDataVisitorCSDL(connection);
            ADOTabularDatabase  db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*");
            ADOTabularModel     m  = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\powerbi-csdl.xml");
            var tabs = new ADOTabularTableCollection(connection, m);

            v.GenerateTablesFromXmlReader(tabs, xr);

            Assert.IsNotNull(m.TOMModel);
            Assert.AreEqual(13, m.TOMModel.Tables.Count, "Table Counts are equal");
            Assert.AreEqual(tabs["ProductCategory"].Columns.Count, m.TOMModel.Tables["ProductCategory"].Columns.Count, "ProductCategory column counts are equal");
            Assert.AreEqual(tabs["Sales"].Relationships.Count, m.TOMModel.Relationships.Count(r => r.FromTable.Name == "Sales"), "Sales table relationships are equal");
            Assert.AreEqual(2, m.TOMModel.Tables["Sales"].Measures.Count, "Sales table measure counts are equal");
        }
        public void TestADOTabularCSDLVisitorKPI()
        {
            ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);
            MetaDataVisitorCSDL  v = new MetaDataVisitorCSDL(c);

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\AdvWrks.xml");
            ADOTabularModel      m  = new ADOTabularModel(c, "Test", "Test Caption", "Test Description", "");
            var tabs = new ADOTabularTableCollection(c, m);

            v.GenerateTablesFromXmlReader(tabs, xr);

            Assert.AreEqual(15, tabs.Count);
            Assert.AreEqual(24, tabs["Sales Territory"].Columns.Count());
            Assert.AreEqual(1, tabs["Sales Territory"].Columns.Where((t) => t.ColumnType == ADOTabularColumnType.Hierarchy).Count());
            var k = tabs["Sales Territory"].Columns["Total Current Quarter Sales Performance"] as ADOTabularKpi;

            Assert.AreEqual("Total Current Quarter Sales Performance", k.Caption);
            Assert.AreEqual("_Total Current Quarter Sales Performance Goal", k.Goal.Caption);
            Assert.AreEqual("_Total Current Quarter Sales Performance Status", k.Status.Caption);
        }
Beispiel #21
0
        public void TestPowerBIOrderByVisitor()
        {
            //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);

            //IADOTabularConnection c = new Mock<IADOTabularConnection>().Object;
            MetaDataVisitorCSDL v  = new MetaDataVisitorCSDL(connection);
            ADOTabularDatabase  db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*");
            ADOTabularModel     m  = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\powerbi-csdl.xml");
            var tabs = new ADOTabularTableCollection(connection, m);

            v.GenerateTablesFromXmlReader(tabs, xr);
            var localDateTable = tabs["LocalDateTable_697ceb23-7c16-46b1-a1ed-0100727de4c7"];

            Assert.IsNotNull(localDateTable);
            Assert.AreEqual(localDateTable.Columns["MonthNo"], localDateTable.Columns["Month"].OrderBy);
            Assert.AreEqual(localDateTable.Columns["QuarterNo"], localDateTable.Columns["Quarter"].OrderBy);
            Assert.IsNull(localDateTable.Columns["Year"].OrderBy);
        }
Beispiel #22
0
        public void TestCSDLNestedMultipleDisplayFolders()
        {
            MetaDataVisitorCSDL v  = new MetaDataVisitorCSDL(connection);
            ADOTabularDatabase  db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*");
            ADOTabularModel     m  = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\NestedMultipleFoldersCsdl.xml");
            var tabs = new ADOTabularTableCollection(connection, m);

            v.GenerateTablesFromXmlReader(tabs, xr);
            var cmpyTab = tabs["Table1"];


            /* test folder structure should be:
             *
             * Folder 1
             |- Measure
             * Folder 2
             +- Folder 3
             +- Measure
             *
             */

            Assert.AreEqual("Table1", cmpyTab.Caption, "Table Name is correct");
            Assert.AreEqual(2, cmpyTab.FolderItems.Count);

            var folder1 = ((IADOTabularFolderReference)cmpyTab.FolderItems[0]);

            Assert.AreEqual("Folder 1", folder1.Name);

            Assert.AreEqual(1, folder1.FolderItems.Count);
            Assert.AreEqual("Measure", folder1.FolderItems[0].InternalReference);
            var folder2 = ((IADOTabularFolderReference)cmpyTab.FolderItems[1]);

            Assert.AreEqual("Folder 2", folder2.Name);

            var folder3 = ((IADOTabularFolderReference)folder2.FolderItems[0]);

            Assert.AreEqual("Folder 3", folder3.Name);
            Assert.AreEqual("Measure", folder3.FolderItems[0].InternalReference);
        }
        public void TestADOTabularCSDLVisitorHierarchies()
        {
            ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);
            MetaDataVisitorCSDL  v = new MetaDataVisitorCSDL(c);

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\AdvWrks.xml");
            ADOTabularModel      m  = new ADOTabularModel(c, "Test", "Test", "Test Description", "");
            var tabs = new ADOTabularTableCollection(c, m);

            v.GenerateTablesFromXmlReader(tabs, xr);

            Assert.AreEqual(15, tabs.Count);
            Assert.AreEqual(24, tabs["Sales Territory"].Columns.Count());
            Assert.AreEqual(1, tabs["Sales Territory"].Columns.Where((t) => t.ColumnType == ADOTabularColumnType.Hierarchy).Count());
            var h = (ADOTabularHierarchy)(tabs["Sales Territory"].Columns.Where((t) => t.ColumnType == ADOTabularColumnType.Hierarchy).First());

            Assert.AreEqual(3, h.Levels.Count);
            Assert.AreEqual("Group", h.Levels[0].LevelName);
            Assert.AreEqual("Country", h.Levels[1].LevelName);
            Assert.AreEqual("Region", h.Levels[2].LevelName);
        }
Beispiel #24
0
        public void TestADOTabularCSDLVisitorMeasures()
        {
            //var c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);

            var v = new MetaDataVisitorCSDL(connection);
            ADOTabularDatabase db = GetTestDB();
            var m    = new ADOTabularModel(connection, db, "AdventureWorks", "AdventureWorks", "Test AdventureWorks", "");
            var tabs = new ADOTabularTableCollection(connection, m);

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\AdvWrks.xml");
            //ADOTabularModel m = new ADOTabularModel(connection, "Test", "Test Caption", "Test Description", "");
            //var tabs = new ADOTabularTableCollection(connection, m);
            v.GenerateTablesFromXmlReader(tabs, xr);


            //foreach (var table in tabs)
            //{
            //    var measures = table.Measures;
            //}

            Assert.AreEqual(1, tabs["Reseller Sales"].Measures.Count, "There should be 1 measure populated by the mocks");
        }
Beispiel #25
0
        public void TestCSDLHierarchInDisplayFolders()
        {
            MetaDataVisitorCSDL v  = new MetaDataVisitorCSDL(connection);
            ADOTabularDatabase  db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*");
            ADOTabularModel     m  = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\HierInFolder.csdl");
            var tabs = new ADOTabularTableCollection(connection, m);

            v.GenerateTablesFromXmlReader(tabs, xr);
            var tabDate = tabs["Date"];

            //var cmpyCol = tabDate.FolderItems.Columns["Internet Current Quarter Sales"];

            //var cmpyCol2 = cmpyTab.Columns["Internet Current Quarter Margin"];

            Assert.AreEqual(1, tabDate.FolderItems.Count, "Table Name is correct");
            Assert.AreEqual("Calendar Folder", tabDate.FolderItems[0].Name);
            Assert.IsInstanceOfType(tabDate.Columns["Calendar"], typeof(ADOTabularHierarchy));
            Assert.AreEqual(true, tabDate.Columns["Calendar"].IsInDisplayFolder);
            //Assert.AreEqual(8, ((IADOTabularFolderReference)cmpyTab.FolderItems[0]).FolderItems.Count);
        }
Beispiel #26
0
        public void TestADOTabularCSDLVisitor()
        {
            //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);

            MetaDataVisitorCSDL v  = new MetaDataVisitorCSDL(connection);
            ADOTabularDatabase  db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*");
            ADOTabularModel     m  = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", "");

            System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\csdl.xml");
            var tabs = new ADOTabularTableCollection(connection, m);

            v.GenerateTablesFromXmlReader(tabs, xr);

            Assert.AreEqual(4, tabs.Count);
            Assert.AreEqual(8, tabs["Sales"].Columns.Count()); // excludes internal rowcount column
            Assert.AreEqual(0, tabs["Sales"].Columns[2].DistinctValues);

            // Check TOM objects

            Assert.AreEqual(4, m.TOMModel.Tables.Count, "Count of tables in TOM Model");
            Assert.AreEqual(4, m.TOMModel.Tables["Sales"].Columns.Count, "Count of columns in TOM Model"); // includes external rowcount column
            Assert.AreEqual(5, m.TOMModel.Tables["Sales"].Measures.Count, "Count of measures in TOM Model");
        }