Skip to content

Commit

Permalink
Update fields for Snowflake data source item and Snowflake data source
Browse files Browse the repository at this point in the history
  • Loading branch information
vulh-infragistics committed Dec 6, 2024
1 parent a6a9d36 commit cace8c2
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Reveal.Sdk.Dom.Core.Extensions;
using Reveal.Sdk.Dom.Core.Constants;
using Reveal.Sdk.Dom.Core.Extensions;
using Reveal.Sdk.Dom.Data;
using Xunit;

Expand All @@ -7,49 +8,60 @@ namespace Reveal.Sdk.Dom.Tests.Data.DataSourceItems
public class SnowflakeDataSourceItemFixture
{
[Theory]
[InlineData("Test Item")]
[InlineData(null)]
public void Constructor_SetsTitleAndDataSource_WhenCalled(string title)
[InlineData("DS Title", "DS Title", "DSI Title", "DSI Title")]
[InlineData(null, "DSI Title", "DSI Title", "DSI Title")]
public void Constructor_CreateSnowFlakeDSI_WithTitleAndDataSource(string dsTitle, string expectedDSTitle, string dsiTitle, string expectedDSITitle)
{
// Arrange
var dataSource = new SnowflakeDataSource();
var dataSource = new DataSource() { Title = dsTitle };

// Act
var item = new SnowflakeDataSourceItem(title, dataSource);
var item = new SnowflakeDataSourceItem(dsiTitle, dataSource);

// Assert
Assert.Equal(title, item.Title);
Assert.Equal(dataSource, item.DataSource);
Assert.Equal(SchemaTypeNames.DataSourceItemType, item.SchemaTypeName);
Assert.Equal(expectedDSTitle, item.DataSource.Title);
Assert.Equal(dataSource.Id, item.DataSource.Id);
Assert.Equal(dataSource.Id, item.DataSourceId);
Assert.IsType<SnowflakeDataSource>(item.DataSource);
Assert.NotSame(dataSource, item.DataSource);
Assert.Equal(expectedDSITitle, item.Title);
}

[Theory]
[InlineData("Test Item")]
[InlineData(null)]
public void Constructor_SetsTitleAndDataSource_WhenConstructedWithGenericDataSource(string title)
[InlineData("DS Title", "DS Title", "DSI Title", "DSI Title")]
[InlineData(null, "DSI Title", "DSI Title", "DSI Title")]
public void Constructor_CreateSnowFlakeDSI_WithTitleAndSnowFlakeDataSource(string dsTitle, string expectedDSTitle, string dsiTitle, string expectedDSITitle)
{
// Arrange
var dataSource = new DataSource();
var dataSource = new SnowflakeDataSource() { Title = dsTitle };

// Act
var item = new SnowflakeDataSourceItem(title, dataSource);
var item = new SnowflakeDataSourceItem(dsiTitle, dataSource);

// Assert
Assert.Equal(title, item.Title);
Assert.Equal(SchemaTypeNames.DataSourceItemType, item.SchemaTypeName);
Assert.Equal(expectedDSTitle, item.DataSource.Title);
Assert.Equal(dataSource.Id, item.DataSource.Id);
Assert.Equal(dataSource.Id, item.DataSourceId);
Assert.IsType<SnowflakeDataSource>(item.DataSource);
Assert.Same(dataSource, item.DataSource);
Assert.Equal(expectedDSITitle, item.Title);
}

[Fact]
public void ProcessDataOnServer_ShouldSetAndGetValue_WithInputs()
public void GetProcessDataOnServer_ReturnSameValue_AfterSet()
{
// Arrange
var item = new SnowflakeDataSourceItem("Test Item", new SnowflakeDataSource());
var expectedProcessDataOnServer = true;

// Act
item.ProcessDataOnServer = true;
item.ProcessDataOnServer = expectedProcessDataOnServer;

// Assert
Assert.True(item.ProcessDataOnServer);
Assert.True(item.Properties.GetValue<bool>("ServerAggregation"));
Assert.Equal(expectedProcessDataOnServer, item.ProcessDataOnServer);
Assert.Equal(expectedProcessDataOnServer, item.Properties.GetValue<bool>("ServerAggregation"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Reveal.Sdk.Dom.Tests.Data.DataSources
public class SnowflakeDataSourceFixture
{
[Fact]
public void SnowflakeDataSource_ShouldSetProviderToSnowflake()
public void Constructor_SetDefaultProvider_WithoutParameter()
{
// Act
var dataSource = new SnowflakeDataSource();
Expand All @@ -19,7 +19,7 @@ public void SnowflakeDataSource_ShouldSetProviderToSnowflake()
[Theory]
[InlineData("testAccount")]
[InlineData(null)]
public void Account_ShouldSetAndGetValue_WithDifferentInputs(string account)
public void GetAccount_ReturnSameValue_AfterSetAccount(string account)
{
// Arrange
var dataSource = new SnowflakeDataSource();
Expand All @@ -35,7 +35,7 @@ public void Account_ShouldSetAndGetValue_WithDifferentInputs(string account)
[Theory]
[InlineData("testRole")]
[InlineData(null)]
public void Role_ShouldSetAndGetValue_WithDifferentInputs(string role)
public void GetRole_ReturnSameValue_AfterSetRole(string role)
{
// Arrange
var dataSource = new SnowflakeDataSource();
Expand All @@ -51,7 +51,7 @@ public void Role_ShouldSetAndGetValue_WithDifferentInputs(string role)
[Theory]
[InlineData("testWarehouse")]
[InlineData(null)]
public void Warehouse_ShouldSetAndGetValue_WithDifferentInputs(string warehouse)
public void SetWarehouse_ReturnSameValue_AfterSetWarehouse(string warehouse)
{
// Arrange
var dataSource = new SnowflakeDataSource();
Expand Down
20 changes: 20 additions & 0 deletions src/Reveal.Sdk.Dom.Tests/Data/TableDataSourceltemFixture.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Moq;
using Reveal.Sdk.Dom.Core.Extensions;
using Reveal.Sdk.Dom.Data;
using Xunit;

Expand Down Expand Up @@ -39,6 +40,25 @@ public void GetTable_ReturnSameValue_WithSetValue()

// Assert
Assert.Equal(expectedTable, tableDataSourceItem.Table);
Assert.Equal(expectedTable, tableDataSourceItem.Properties.GetValue<string>("Table"));
}

[Fact]
public void GetCustomQuery_ReturnSameValue_WithSetValue()
{
// Arrange
var title = "Title";
var dataSource = new DataSource();
var mock = new Mock<TableDataSourceItem>(title, dataSource);
var tableDataSourceItem = mock.Object;
var expectedCustomQuery = "Select FieldA, FieldB from SampleTable;";

// Act
tableDataSourceItem.CustomQuery = expectedCustomQuery;

// Assert
Assert.Equal(expectedCustomQuery, tableDataSourceItem.CustomQuery);
Assert.Equal(expectedCustomQuery, tableDataSourceItem.Parameters.GetValue<string>("RPCustomQuery"));
}
}
}
2 changes: 1 addition & 1 deletion src/Reveal.Sdk.Dom/Data/DataSources/SnowflakeDataSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Reveal.Sdk.Dom.Data
{
public class SnowflakeDataSource : ProcessDataSource
public class SnowflakeDataSource : SchemaDataSource
{
public SnowflakeDataSource()
{
Expand Down
7 changes: 7 additions & 0 deletions src/Reveal.Sdk.Dom/Data/TableDataSourceItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,12 @@ public string Table
get => Properties.GetValue<string>("Table");
set => Properties.SetItem("Table", value);
}

[JsonIgnore]
public string CustomQuery
{
get => Parameters.GetValue<string>("RPCustomQuery");
set => Parameters.SetItem("RPCustomQuery", value);
}
}
}

0 comments on commit cace8c2

Please sign in to comment.