Esempio n. 1
0
        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);
            }
        }
Esempio n. 2
0
        public void TestDisplayFolders()
        {
            MetaDataVisitorCSDL v   = new MetaDataVisitorCSDL(connection);
            ADOTabularModel     m   = new ADOTabularModel(connection, "Test", "Test", "Test Description", "");
            var mockEventAggregator = new Mock <IEventAggregator>().Object;
            var mockMetadata        = new Mock <IMetadataPane>().Object;
            var tt = m.TreeViewTables(mockOptions, mockEventAggregator, mockMetadata);

            Assert.AreEqual(7, tt.Count, "Correct Table Count");


            var tbl = tt.FirstOrDefault(x => x.Name == "Internet Sales");

            Assert.IsNotNull(tbl, "Could not find 'Internet Sales' table");

            var folder = ((TreeViewColumn)tbl.Children.FirstOrDefault(x => ((TreeViewColumn)x).Name == "QTD Folder"));

            Assert.IsNotNull(folder, "Folder Object not found");
            Assert.AreEqual(folder.Name, "QTD Folder");

            TreeViewColumn col = folder.Children.FirstOrDefault(x => x.Name == "Internet Current Quarter Margin") as TreeViewColumn;

            Assert.IsInstanceOfType(col, typeof(TreeViewColumn));
            Assert.AreEqual(MetadataImages.Measure, col.MetadataImage);
        }
Esempio n. 3
0
        public void RefreshMetadata()
        {
            var _tmpModel = _selectedModel;

            _selectedModel = null;
            SelectedModel  = _tmpModel;
        }
Esempio n. 4
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");
        }
Esempio n. 5
0
        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 TestSecondDisplayFolderWithHierarchy()
        {
            MetaDataVisitorCSDL v   = new MetaDataVisitorCSDL(connection);
            ADOTabularDatabase  db  = GetTestDB();
            ADOTabularModel     m   = new ADOTabularModel(connection, db, "Test", "Test", "Test Description", "");
            var mockEventAggregator = new Mock <IEventAggregator>().Object;
            var mockMetadata        = new Mock <IMetadataPane>().Object;
            var tt = m.TreeViewTables(mockOptions, mockEventAggregator, mockMetadata);

            Assert.AreEqual(2, tt.Count, "Correct Table Count");


            var tbl = tt.FirstOrDefault(x => x.Name == "Calendar");

            Assert.IsNotNull(tbl, "Could not find 'Date' table");

            var folder = ((TreeViewColumn)tbl.Children.FirstOrDefault(x => ((TreeViewColumn)x).Name == "Dates"));

            Assert.IsNotNull(folder, "Folder Object not found");
            Assert.AreEqual(folder.Name, "Dates");

            TreeViewColumn col = folder.Children.FirstOrDefault(x => x.Name == "Date_Hierarchy1") as TreeViewColumn;

            Assert.IsInstanceOfType(col, typeof(TreeViewColumn));
            Assert.AreEqual(MetadataImages.Hierarchy, col.MetadataImage);
        }
Esempio n. 7
0
        public static List <FilterableTreeViewItem> TreeViewTables(this ADOTabularModel model, IGlobalOptions options, IEventAggregator eventAggregator)
        {
            var lst = new List <FilterableTreeViewItem>();

            foreach (var t in model.Tables)
            {
                lst.Add(new TreeViewTable(t, t.TreeViewColumns, options, eventAggregator));
            }
            return(lst);
        }
Esempio n. 8
0
        public static List <FilterableTreeViewItem> TreeViewTables(this ADOTabularModel model)
        {
            var lst = new List <FilterableTreeViewItem>();

            foreach (var t in model.Tables)
            {
                lst.Add(new TreeViewTable(t, t.TreeViewColumns));
            }
            return(lst);
        }
Esempio n. 9
0
        public void TestADOTabularCSDLVisitorMeasures()
        {
            var c    = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices);
            var v    = new MetaDataVisitorCSDL(c);
            var m    = new ADOTabularModel(c, "AdventureWorks", "AdventureWorks", "Test AdventureWorks", "");
            var tabs = new ADOTabularTableCollection(c, m);

            foreach (var table in tabs)
            {
                var measures = table.Measures;
            }
        }
Esempio n. 10
0
        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");
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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);
        }
Esempio n. 13
0
        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());
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
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);
        }
Esempio n. 16
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");
        }
Esempio n. 17
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");
        }
Esempio n. 18
0
        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");
        }
Esempio n. 19
0
        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);
        }
Esempio n. 20
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);
        }
Esempio n. 21
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);
        }
Esempio n. 22
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);
        }
Esempio n. 23
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;
            }
        }
Esempio n. 24
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");
        }
Esempio n. 25
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);
        }
Esempio n. 26
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");
        }
Esempio n. 27
0
        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);
        }
Esempio n. 28
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);
        }
Esempio n. 29
0
        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);
        }
Esempio n. 30
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");
        }