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); } }
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); }
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"); }
private static DataTable GetColumnCardinality(ADOTabularDatabase database) { var cnn = database.Connection; var tbl = cnn.ExecuteDaxQueryDataTable(Queries.Constants.ColumnCardinality); return(tbl); }
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 TestDisplayFolders() { 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(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)); if (col != null) { Assert.AreEqual(MetadataImages.Measure, col.MetadataImage); } }
private static void ProcessCatalog(DatabaseProfile profile, ADOTabularDatabase database) { var tbl = GetCatalog(database); DataRow dr = tbl.Rows[0]; profile.ModifiedDate = dr.Field <DateTime>("DATE_MODIFIED"); }
private static DataTable GetCatalog(ADOTabularDatabase database) { var cnn = database.Connection; var tbl = cnn.ExecuteDaxQueryDataTable(string.Format("SELECT * FROM $SYSTEM.DBSCHEMA_CATALOGS WHERE [CATALOG_NAME] = '{0}'", database.Name)); return(tbl); }
private static DataTable GetTables(ADOTabularDatabase database) { var cnn = database.Connection; var tbl = cnn.ExecuteDaxQueryDataTable(Queries.Constants.Tables); return(tbl); }
public void MyTestInitialize() { var mockConn = new Mock <IADOTabularConnection>(); var columnCollection = new Dictionary <string, ADOTabularColumn>(); mockConn.SetupGet(x => x.Columns).Returns(columnCollection); mockConn.Setup(x => x.GetSchemaDataSet("DISCOVER_KEYWORDS", null, false)).Returns(keywordDataSet); mockConn.Setup(x => x.GetSchemaDataSet("MDSCHEMA_FUNCTIONS", null, false)).Returns(functionDataSet); mockConn.Setup(x => x.GetSchemaDataSet("MDSCHEMA_CUBES", It.IsAny <AdomdRestrictionCollection>())).Returns(cubesDataSet); mockConn.Setup(x => x.ShowHiddenObjects).Returns(true); var mockDb = new Mock <ADOTabularDatabase>(mockConn.Object, "Adventure Works", "Adventure Works", new DateTime(2017, 7, 20), "1400", "*"); mockDatabase = mockDb.Object; mockConn.SetupGet(x => x.Database).Returns(mockDatabase); mockConn.Setup(x => x.GetSchemaDataSet( "MDSCHEMA_MEASURES", It.Is <AdomdRestrictionCollection>(res => IsResellerSalesMeasureGroup(res)), false)) .Returns(measureDataSet); mockConn.Setup(x => x.GetSchemaDataSet( "MDSCHEMA_MEASURES", It.Is <AdomdRestrictionCollection>(res => !IsResellerSalesMeasureGroup(res)), false)) .Returns(measureDataSetEmpty); mockConn.Setup(x => x.GetSchemaDataSet( "MDSCHEMA_MEASURES", It.Is <AdomdRestrictionCollection>(res => IsResellerSalesMeasureGroup(res)) )) .Returns(measureDataSet); mockConn.Setup(x => x.GetSchemaDataSet( "MDSCHEMA_MEASURES", It.Is <AdomdRestrictionCollection>(res => !IsResellerSalesMeasureGroup(res)) )) .Returns(measureDataSetEmpty); mockConn.Setup(x => x.GetSchemaDataSet( "DISCOVER_CSDL_METADATA", It.IsAny <AdomdRestrictionCollection>() )) .Returns(csdlMetaDataRowset); mockConn.Setup(x => x.GetSchemaDataSet( "MDSCHEMA_HIERARCHIES", It.IsAny <AdomdRestrictionCollection>() )) .Returns(emptyDataSet); mockConn.Setup(x => x.ServerVersion).Returns("15.0.0"); mockConn.SetupGet(x => x.Visitor).Returns(new MetaDataVisitorCSDL(mockConn.Object)); mockConn.SetupGet(x => x.Keywords).Returns(new ADOTabularKeywordCollection(mockConn.Object)); mockConn.SetupGet(x => x.AllFunctions).Returns(new List <string>()); connection = mockConn.Object; }
private static void ProcessColumnCardinality(DatabaseProfile profile, ADOTabularDatabase database) { var tbl = GetColumnCardinality(database); foreach (DataRow dr in tbl.Rows) { var tab = profile.Tables[dr["TABLE_NAME"].ToString()]; var hierId = dr["COLUMN_HIERARCHY_ID"].ToString(); var colId = hierId.Substring(hierId.IndexOf('$', 3) + 1); var col = tab.Columns.GetById(colId); col.Cardinality = dr.Field <long>("COLUMN_CARDINALITY"); } }
private static void ProcessColumns(DatabaseProfile profile, ADOTabularDatabase database) { var tbl = GetColumns(database); foreach (DataRow dr in tbl.Rows) { profile.Tables[dr["TABLE_NAME"].ToString()].Columns.Add(new Column() { Name = dr["COLUMN_NAME"].ToString(), Id = dr["COLUMN_ID"].ToString(), DataType = dr["DATATYPE"].ToString(), DictionarySize = dr.Field <ulong>("DICTIONARY_SIZE_BYTES") }); } }
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); }
private static void ProcessTables(DatabaseProfile profile, ADOTabularDatabase database) { var tbl = GetTables(database); foreach (DataRow dr in tbl.Rows) { profile.Tables.Add(new Table() { Name = dr["TABLE_NAME"].ToString(), Id = dr["TABLE_ID"].ToString(), RowCount = dr.Field <long>("ROWS_IN_TABLE"), RiViolationCount = dr.Field <long>("RIVIOLATION_COUNT") }); } }
public void TestCSDLTablesWithSpaces() { //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["Sales Quota"]; Assert.AreEqual("Sales Quota", cmpyTab.Caption, "Table Name is translated"); }
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); }
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); }
public static DatabaseProfile Create(ADOTabularDatabase database) { DatabaseProfile profile = new DatabaseProfile() { Name = database.Name, Id = database.Id, ProfileDate = DateTime.Now }; ProcessCatalog(profile, database); ProcessTables(profile, database); ProcessColumns(profile, database); ProcessColumnSegments(profile, database); ProcessColumnCardinality(profile, database); return(profile); }
public void TestADOTabularLargeCSDLVisitor() { //ADOTabularConnection connection = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices); MetaDataVisitorCSDL visitor = new MetaDataVisitorCSDL(connection); ADOTabularDatabase db = new ADOTabularDatabase(connection, "Test", "Test", DateTime.Parse("2019-09-01 09:00:00"), "1200", "*"); ADOTabularModel model = new ADOTabularModel(connection, db, "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.ObjectType == ADOTabularObjectType.Column).Count()); Assert.AreEqual(347, tabs["Orders"].Columns.Where(c => c.ObjectType == ADOTabularObjectType.Measure).Count()); }
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); //IADOTabularConnection c = new Mock<IADOTabularConnection>().Object; //c.Open(); 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\aw_internetsales_2014_csdl.xml"); var tabs = new ADOTabularTableCollection(connection, m); v.GenerateTablesFromXmlReader(tabs, xr); var cmpyTab = tabs["Internet Sales"]; Assert.AreEqual("Internet Sales", cmpyTab.Caption, "Table Name is translated"); }
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); }
public void TestCSDLDisplayFolders() { 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\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); }
public void TestPowerBIVariationsVisitor() { //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 promoTable = tabs["Promotion"]; Assert.IsNotNull(promoTable); Assert.AreEqual(0, promoTable.Columns["PromotionName"].Variations.Count); Assert.AreEqual(1, promoTable.Columns["StartDate"].Variations.Count); }
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 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; } }
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); }
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 TestADOTabularCSDLVisitorKPI() { //ADOTabularConnection c = new ADOTabularConnection(ConnectionString, AdomdType.AnalysisServices); //IADOTabularConnection c = new Mock<IADOTabularConnection>().Object; MetaDataVisitorCSDL v = new MetaDataVisitorCSDL(connection); System.Xml.XmlReader xr = new System.Xml.XmlTextReader(@"..\..\data\AdvWrks.xml"); ADOTabularDatabase db = GetTestDB(); ADOTabularModel m = new ADOTabularModel(connection, db, "Test", "Test Caption", "Test Description", ""); var tabs = new ADOTabularTableCollection(connection, 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.ObjectType == ADOTabularObjectType.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); }
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"); }