From 67d3f08fb87268f20ea93b8423b3bf61d0228029 Mon Sep 17 00:00:00 2001 From: Viktor Date: Wed, 11 Dec 2024 16:22:13 +0700 Subject: [PATCH 1/3] Create / update constructors and unit tests for MS Azure Snapse --- ...reSynapseAnalyticsDataSourceItemFixture.cs | 43 ++++++++++++++++--- ...tAzureSynapseAnalyticsDataSourceFixture.cs | 7 +-- ...softAzureSynapseAnalyticsDataSourceItem.cs | 15 ++++++- ...icrosoftAzureSynapseAnalyticsDataSource.cs | 2 +- 4 files changed, 52 insertions(+), 15 deletions(-) diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/MicrosoftAzureSynapseAnalyticsDataSourceItemFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/MicrosoftAzureSynapseAnalyticsDataSourceItemFixture.cs index 036da5f4..bc3c2b50 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/MicrosoftAzureSynapseAnalyticsDataSourceItemFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSourceItems/MicrosoftAzureSynapseAnalyticsDataSourceItemFixture.cs @@ -1,23 +1,33 @@ using Reveal.Sdk.Dom.Data; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Xunit; namespace Reveal.Sdk.Dom.Tests.Data.DataSourceItems { public class MicrosoftAzureSynapseAnalyticsDataSourceItemFixture { + [Fact] + public void Constructor_CreateAzureSynapseDSItem_WithTitle() + { + // Arrange + var expectedDSItemTitle = "Azure Synapse DSI Title"; + + // Act + var dataSourceItem = new MicrosoftAzureSynapseAnalyticsDataSourceItem(expectedDSItemTitle); + + // Assert + Assert.Equal(expectedDSItemTitle, dataSourceItem.Title); + Assert.NotNull(dataSourceItem.DataSource); + Assert.Equal(expectedDSItemTitle, dataSourceItem.DataSource.Title); + Assert.IsType(dataSourceItem.DataSource); + } [Theory] [InlineData("DS Title", "DS Item Title", "DS Title", "DS Item Title")] [InlineData(null, "DS Item Title", "DS Item Title", "DS Item Title")] - public void Constructor_SetsTitleAndDatasource_AsProvided(string dSTitle, string dSItemTitle, string expectedDSTitle, string expectedDSItemTitle) + public void Constructor_CreateDataSource_WithTitleAndDataSource(string dSTitle, string dSItemTitle, string expectedDSTitle, string expectedDSItemTitle) { // Arrange - var dataSource = new MicrosoftAzureSynapseAnalyticsDataSource() { Title = dSTitle }; + var dataSource = new DataSource() { Title = dSTitle }; // Act var dataSourceItem = new MicrosoftAzureSynapseAnalyticsDataSourceItem(dSItemTitle, dataSource); @@ -27,8 +37,27 @@ public void Constructor_SetsTitleAndDatasource_AsProvided(string dSTitle, string Assert.Equal(dataSource, dataSourceItem.DataSource); Assert.Equal(dataSource.Id, dataSourceItem.DataSourceId); Assert.Equal(expectedDSTitle, dataSourceItem.DataSource.Title); + Assert.NotSame(dataSource, dataSourceItem.DataSource); + Assert.IsType(dataSourceItem.DataSource); + } + + [Theory] + [InlineData("DS Title", "DS Item Title", "DS Title", "DS Item Title")] + [InlineData(null, "DS Item Title", "DS Item Title", "DS Item Title")] + public void Constructor_CreateDataSource_WithTitleAndAzureSynapseDataSource(string dSTitle, string dSItemTitle, string expectedDSTitle, string expectedDSItemTitle) + { + // Arrange + var dataSource = new MicrosoftAzureSynapseAnalyticsDataSource() { Title = dSTitle }; + + // Act + var dataSourceItem = new MicrosoftAzureSynapseAnalyticsDataSourceItem(dSItemTitle, dataSource); + + // Assert + Assert.Equal(expectedDSItemTitle, dataSourceItem.Title); Assert.Equal(dataSource, dataSourceItem.DataSource); Assert.Equal(dataSource.Id, dataSourceItem.DataSourceId); + Assert.Equal(expectedDSTitle, dataSourceItem.DataSource.Title); + Assert.Same(dataSource, dataSourceItem.DataSource); } } } diff --git a/src/Reveal.Sdk.Dom.Tests/Data/DataSources/MicrosoftAzureSynapseAnalyticsDataSourceFixture.cs b/src/Reveal.Sdk.Dom.Tests/Data/DataSources/MicrosoftAzureSynapseAnalyticsDataSourceFixture.cs index adcff4c1..9df4f217 100644 --- a/src/Reveal.Sdk.Dom.Tests/Data/DataSources/MicrosoftAzureSynapseAnalyticsDataSourceFixture.cs +++ b/src/Reveal.Sdk.Dom.Tests/Data/DataSources/MicrosoftAzureSynapseAnalyticsDataSourceFixture.cs @@ -1,9 +1,4 @@ using Reveal.Sdk.Dom.Data; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Xunit; namespace Reveal.Sdk.Dom.Tests.Data.DataSources @@ -11,7 +6,7 @@ namespace Reveal.Sdk.Dom.Tests.Data.DataSources public class MicrosoftAzureSynapseAnalyticsDataSourceFixture { [Fact] - public void Constructor_SetProviderToMicrosoftAzureSqlServer_WhenConstructed() + public void Constructor_SetProviderToMicrosoftAzureSynapseAnalytics_WithoutParameters() { // Act var dataSource = new MicrosoftAzureSynapseAnalyticsDataSource(); diff --git a/src/Reveal.Sdk.Dom/Data/DataSourceItems/MicrosoftAzureSynapseAnalyticsDataSourceItem.cs b/src/Reveal.Sdk.Dom/Data/DataSourceItems/MicrosoftAzureSynapseAnalyticsDataSourceItem.cs index 5ff9846a..66a212e5 100644 --- a/src/Reveal.Sdk.Dom/Data/DataSourceItems/MicrosoftAzureSynapseAnalyticsDataSourceItem.cs +++ b/src/Reveal.Sdk.Dom/Data/DataSourceItems/MicrosoftAzureSynapseAnalyticsDataSourceItem.cs @@ -1,9 +1,22 @@ namespace Reveal.Sdk.Dom.Data { - internal class MicrosoftAzureSynapseAnalyticsDataSourceItem : MicrosoftSqlServerDataSourceItem + public class MicrosoftAzureSynapseAnalyticsDataSourceItem : MicrosoftSqlServerDataSourceItem { + public MicrosoftAzureSynapseAnalyticsDataSourceItem(string title) : + base(title, new MicrosoftAzureSynapseAnalyticsDataSource()) + { } + public MicrosoftAzureSynapseAnalyticsDataSourceItem(string title, DataSource dataSource) : base(title, dataSource) { } + + public MicrosoftAzureSynapseAnalyticsDataSourceItem(string title, MicrosoftAzureSynapseAnalyticsDataSource dataSource) + : base(title, dataSource) + { } + + protected override DataSource CreateDataSourceInstance(DataSource dataSource) + { + return Create(dataSource); + } } } diff --git a/src/Reveal.Sdk.Dom/Data/DataSources/MicrosoftAzureSynapseAnalyticsDataSource.cs b/src/Reveal.Sdk.Dom/Data/DataSources/MicrosoftAzureSynapseAnalyticsDataSource.cs index 12ee17b9..5f5ea749 100644 --- a/src/Reveal.Sdk.Dom/Data/DataSources/MicrosoftAzureSynapseAnalyticsDataSource.cs +++ b/src/Reveal.Sdk.Dom/Data/DataSources/MicrosoftAzureSynapseAnalyticsDataSource.cs @@ -1,6 +1,6 @@ namespace Reveal.Sdk.Dom.Data { - internal class MicrosoftAzureSynapseAnalyticsDataSource : MicrosoftAzureSqlServerDataSource + public class MicrosoftAzureSynapseAnalyticsDataSource : MicrosoftAzureSqlServerDataSource { public MicrosoftAzureSynapseAnalyticsDataSource() { From a1da22d1635447dd79e619687a2c2ef1ed616c5a Mon Sep 17 00:00:00 2001 From: Viktor Date: Wed, 11 Dec 2024 17:07:21 +0700 Subject: [PATCH 2/3] Create Azure Synapse Analytics sandbox example --- .../MSAzureSynapseAnalyticsDashboard.cs | 44 +++++++++++++++++++ e2e/Sandbox/MainWindow.xaml.cs | 1 + e2e/Sandbox/Reveal/AuthenticationProvider.cs | 6 ++- 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 e2e/Sandbox/DashboardCreators/MSAzureSynapseAnalyticsDashboard.cs diff --git a/e2e/Sandbox/DashboardCreators/MSAzureSynapseAnalyticsDashboard.cs b/e2e/Sandbox/DashboardCreators/MSAzureSynapseAnalyticsDashboard.cs new file mode 100644 index 00000000..2170cc97 --- /dev/null +++ b/e2e/Sandbox/DashboardCreators/MSAzureSynapseAnalyticsDashboard.cs @@ -0,0 +1,44 @@ +using Reveal.Sdk.Dom; +using Reveal.Sdk.Dom.Data; +using Reveal.Sdk.Dom.Visualizations; +using System.Collections.Generic; + +namespace Sandbox.DashboardFactories +{ + internal class MSAzureSynapseAnalyticsDashboard : IDashboardCreator + { + public string Name => "Azure Synapse Analytics Data Source"; + + public RdashDocument CreateDashboard() + { + var document = new RdashDocument("Azure Synapse Analytics Dashboard"); + + var dataSource = new MicrosoftAzureSynapseAnalyticsDataSource() + { + Id = "azureSynapseDSId", + Title = "Synapse data source title", + Host = "revealdb01.infragistics.local", + Database = "Northwind", + Port = 1433 + }; + var dataSourceItem = new MicrosoftAzureSynapseAnalyticsDataSourceItem("MS Azure Synapse DS Item", dataSource) + { + Id = "azureSynapseDSItemId", + Title = "Synapse DS item title", + Database = dataSource.Database, + Table = "Categories", + Fields = new List + { + new NumberField("CategoryID"), + new TextField("CategoryName"), + new TextField("Description") + } + }; + + document.Visualizations.Add(new GridVisualization("List Categories", dataSourceItem) + .SetColumns("CategoryID", "CategoryName", "Description")); + + return document; + } + } +} diff --git a/e2e/Sandbox/MainWindow.xaml.cs b/e2e/Sandbox/MainWindow.xaml.cs index 587bbcd5..7bcfd338 100644 --- a/e2e/Sandbox/MainWindow.xaml.cs +++ b/e2e/Sandbox/MainWindow.xaml.cs @@ -64,6 +64,7 @@ public partial class MainWindow : Window new MSAzureSqlServerDSDashboard(), new ODataDashboard(), new OracleDashboard(), + new MSAzureSynapseAnalyticsDashboard(), new PostgresqlDashboard(), new RestDataSourceDashboard(), new SalesDashboard(), diff --git a/e2e/Sandbox/Reveal/AuthenticationProvider.cs b/e2e/Sandbox/Reveal/AuthenticationProvider.cs index 971757e9..02ff732b 100644 --- a/e2e/Sandbox/Reveal/AuthenticationProvider.cs +++ b/e2e/Sandbox/Reveal/AuthenticationProvider.cs @@ -24,7 +24,11 @@ internal class AuthenticationProvider : IRVAuthenticationProvider public Task ResolveCredentialsAsync(RVDashboardDataSource dataSource) { IRVDataSourceCredential userCredential = null; - if (dataSource is RVAzureSqlDataSource) + if (dataSource is RVAzureSynapseDataSource) + { + userCredential = new RVUsernamePasswordDataSourceCredential("azure-synapse-username", "password", "domain"); + } + else if (dataSource is RVAzureSqlDataSource) { userCredential = new RVUsernamePasswordDataSourceCredential("azure-username", "password"); } From 7b9daf5665bfed5cc0558b3865ad5cfbf76143de Mon Sep 17 00:00:00 2001 From: Viktor Date: Thu, 12 Dec 2024 18:06:36 +0700 Subject: [PATCH 3/3] Update sandbox --- .../DashboardCreators/MSAzureSynapseAnalyticsDashboard.cs | 5 +++-- e2e/Sandbox/MainWindow.xaml.cs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/e2e/Sandbox/DashboardCreators/MSAzureSynapseAnalyticsDashboard.cs b/e2e/Sandbox/DashboardCreators/MSAzureSynapseAnalyticsDashboard.cs index 2170cc97..63f0f6f4 100644 --- a/e2e/Sandbox/DashboardCreators/MSAzureSynapseAnalyticsDashboard.cs +++ b/e2e/Sandbox/DashboardCreators/MSAzureSynapseAnalyticsDashboard.cs @@ -7,7 +7,7 @@ namespace Sandbox.DashboardFactories { internal class MSAzureSynapseAnalyticsDashboard : IDashboardCreator { - public string Name => "Azure Synapse Analytics Data Source"; + public string Name => "MS Azure Synapse Analytics Data Source"; public RdashDocument CreateDashboard() { @@ -19,7 +19,8 @@ public RdashDocument CreateDashboard() Title = "Synapse data source title", Host = "revealdb01.infragistics.local", Database = "Northwind", - Port = 1433 + Port = 1433, + TrustServerCertificate = false }; var dataSourceItem = new MicrosoftAzureSynapseAnalyticsDataSourceItem("MS Azure Synapse DS Item", dataSource) { diff --git a/e2e/Sandbox/MainWindow.xaml.cs b/e2e/Sandbox/MainWindow.xaml.cs index 7bcfd338..18e11efc 100644 --- a/e2e/Sandbox/MainWindow.xaml.cs +++ b/e2e/Sandbox/MainWindow.xaml.cs @@ -60,11 +60,11 @@ public partial class MainWindow : Window new MSAnalysisServiceDashboard(), new MSAzureAnalysisServiceDashboard(), new MSAzureSqlDashboard(), + new MSAzureSynapseAnalyticsDashboard(), new MySqlDashboard(), new MSAzureSqlServerDSDashboard(), new ODataDashboard(), new OracleDashboard(), - new MSAzureSynapseAnalyticsDashboard(), new PostgresqlDashboard(), new RestDataSourceDashboard(), new SalesDashboard(),