Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests or database datasource and items #97

Merged
merged 3 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Reveal.Sdk.Dom.Core.Extensions;
using Reveal.Sdk.Dom.Data;
using Xunit;

namespace Reveal.Sdk.Dom.Tests.Data.DataSourceItems
{
public class MongoDbDataSourceItemFixture
{
[Theory]
[InlineData("Test Item")]
[InlineData(null)]
public void Constructor_SetsTitleAndDataSource_WhenCalled(string title)
{
// Arrange
var dataSource = new MongoDBDataSource();

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

// Assert
Assert.Equal(title, item.Title);
Assert.Equal(dataSource, item.DataSource);
}

[Fact]
public void Collection_SetsAndGetsValue_WithInputs()
{
// Arrange
var item = new MongoDbDataSourceItem("Test Item", new MongoDBDataSource());

// Act
item.Collection = "TestCollection";

// Assert
Assert.Equal("TestCollection", item.Collection);
Assert.Equal("TestCollection", item.Properties.GetValue<string>("Collection"));
}

[Fact]
public void ProcessDataOnServer_SetsAndGetsValue_WithInputs()
{
// Arrange
var item = new MongoDbDataSourceItem("Test Item", new MongoDBDataSource());

// Act
item.ProcessDataOnServer = true;

// Assert
Assert.True(item.ProcessDataOnServer);
Assert.True(item.Properties.GetValue<bool>("ServerAggregation"));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Reveal.Sdk.Dom.Core.Extensions;
using Reveal.Sdk.Dom.Data;
using Xunit;

namespace Reveal.Sdk.Dom.Tests.Data.DataSourceItems
{
public class MySqlDataSourceItemFixture
{
[Theory]
[InlineData("Test Item")]
[InlineData(null)]
public void Constructor_SetsTitleAndDataSource_WhenCalled(string title)
{
// Arrange
var dataSource = new MySQLDataSource();

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

// Assert
Assert.Equal(title, item.Title);
Assert.Equal(dataSource, item.DataSource);
recca5p marked this conversation as resolved.
Show resolved Hide resolved
}


[Fact]
public void ProcessDataOnServer_SetsAndGetsValue_WithInputs()
{
// Arrange
var item = new MySqlDataSourceItem("Test Item", new MySQLDataSource());

// Act
item.ProcessDataOnServer = true;

// Assert
Assert.True(item.ProcessDataOnServer);
Assert.True(item.Properties.GetValue<bool>("ServerAggregation"));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Reveal.Sdk.Dom.Data;
using Xunit;

namespace Reveal.Sdk.Dom.Tests.Data.DataSourceItems
{
public class OracleDataSourceItemFixture
{
[Theory]
[InlineData("Test Item")]
[InlineData(null)]
public void Constructor_SetsTitleAndDataSource_WhenCalled(string title)
{
// Arrange
var dataSource = new OracleDataSource();

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

// Assert
Assert.Equal(title, item.Title);
Assert.Equal(dataSource, item.DataSource);
recca5p marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Reveal.Sdk.Dom.Core.Extensions;
using Reveal.Sdk.Dom.Data;
using Xunit;

namespace Reveal.Sdk.Dom.Tests.Data.DataSourceItems
{
public class PostgreSqlDataSourceItemFixture
{
[Theory]
[InlineData("Test Item")]
[InlineData(null)]
public void Constructor_SetsTitleAndDataSource_WhenCalled(string title)
{
// Arrange
var dataSource = new PostgreSQLDataSource();

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

// Assert
Assert.Equal(title, item.Title);
Assert.Equal(dataSource, item.DataSource);
recca5p marked this conversation as resolved.
Show resolved Hide resolved
}

[Fact]
public void ProcessDataOnServer_SetsAndGetsValue_WithInputs()
{
// Arrange
var item = new PostgreSqlDataSourceItem("Test Item", new PostgreSQLDataSource());

// Act
item.ProcessDataOnServer = true;

// Assert
Assert.True(item.ProcessDataOnServer);
Assert.True(item.Properties.GetValue<bool>("ServerAggregation"));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,35 +1,55 @@
using Reveal.Sdk.Dom.Data;
using Reveal.Sdk.Dom.Core.Extensions;
using Reveal.Sdk.Dom.Data;
using Xunit;

namespace Reveal.Sdk.Dom.Tests.Data.DataSourceItems
{
public class SnowflakeDataSourceItemFixture
{
[Fact]
public void ProcessDataOnServer_Should_GetAndSetProperties()
[Theory]
[InlineData("Test Item")]
[InlineData(null)]
public void Constructor_SetsTitleAndDataSource_WhenCalled(string title)
{
// Arrange
var dataSource = new SnowflakeDataSource();
var dataSourceItem = new SnowflakeDataSourceItem("Test", dataSource);

// Act
dataSourceItem.ProcessDataOnServer = true;
var processDataOnServer = dataSourceItem.ProcessDataOnServer;
var item = new SnowflakeDataSourceItem(title, dataSource);

// Assert
Assert.True(processDataOnServer);
Assert.Equal(title, item.Title);
Assert.Equal(dataSource, item.DataSource);
recca5p marked this conversation as resolved.
Show resolved Hide resolved
}

[Fact]
public void CreateDataSourceInstance_Should_ReturnSnowflakeDataSourceInstance()
[Theory]
[InlineData("Test Item")]
[InlineData(null)]
public void Constructor_SetsTitleAndDataSource_WhenConstructedWithGenericDataSource(string title)
{
// Arrange
var dataSource = new DataSource();
var dataSourceItem = new SnowflakeDataSourceItem("Test", dataSource);

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

// Assert
Assert.Equal(title, item.Title);
Assert.IsType<SnowflakeDataSource>(item.DataSource);
recca5p marked this conversation as resolved.
Show resolved Hide resolved
}

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

// Act
item.ProcessDataOnServer = true;

// Assert
Assert.IsType<SnowflakeDataSource>(dataSourceItem.DataSource);
Assert.True(item.ProcessDataOnServer);
Assert.True(item.Properties.GetValue<bool>("ServerAggregation"));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
using Reveal.Sdk.Dom.Core.Extensions;
using Reveal.Sdk.Dom.Data;
using Xunit;

namespace Reveal.Sdk.Dom.Tests.Data.DataSources
{
public class MongoDbDataSourceItemFixture
{
[Fact]
public void Constructor_SetsProviderToMongoDB_WhenConstructed()
{
// Act
var dataSource = new MongoDBDataSource();

// Assert
Assert.Equal(DataSourceProvider.MongoDB, dataSource.Provider);
}

[Theory]
[InlineData("mongodb://localhost:27017")]
[InlineData(null)]
public void ConnectionString_SetsAndGetsValue_WithDifferentInputs(string connectionString)
{
// Arrange
var dataSource = new MongoDBDataSource();

// Act
dataSource.ConnectionString = connectionString;

// Assert
Assert.Equal(connectionString, dataSource.ConnectionString);
Assert.Equal(connectionString, dataSource.Properties.GetValue<string>("ConnectionString"));
}

[Theory]
[InlineData(true)]
recca5p marked this conversation as resolved.
Show resolved Hide resolved
[InlineData(false)]
public void ProcessDataOnServerDefaultValue_SetsAndGetsValue_WithDifferentInputs(bool defaultValue)
{
// Arrange
var dataSource = new MongoDBDataSource();

// Act
dataSource.ProcessDataOnServerDefaultValue = defaultValue;

// Assert
Assert.Equal(defaultValue, dataSource.ProcessDataOnServerDefaultValue);
Assert.Equal(defaultValue, dataSource.Properties.GetValue<bool>("ServerAggregationDefault"));
}

[Theory]
[InlineData(true)]
recca5p marked this conversation as resolved.
Show resolved Hide resolved
[InlineData(false)]
public void ProcessDataOnServerReadOnly_SetsAndGetsValue_WithDifferentInputs(bool readOnlyValue)
{
// Arrange
var dataSource = new MongoDBDataSource();

// Act
dataSource.ProcessDataOnServerReadOnly = readOnlyValue;

// Assert
Assert.Equal(readOnlyValue, dataSource.ProcessDataOnServerReadOnly);
Assert.Equal(readOnlyValue, dataSource.Properties.GetValue<bool>("ServerAggregationReadOnly"));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Reveal.Sdk.Dom.Data;
using Xunit;

namespace Reveal.Sdk.Dom.Tests.Data.DataSources
{
public class MySQLDataSourceFixture
{
[Fact]
public void Constructor_SetsProviderToMySQL_WhenConstructed()
{
// Act
var dataSource = new MySQLDataSource();

// Assert
Assert.Equal(DataSourceProvider.MySQL, dataSource.Provider);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Reveal.Sdk.Dom.Core.Extensions;
using Reveal.Sdk.Dom.Data;
using Xunit;

namespace Reveal.Sdk.Dom.Tests.Data.DataSources
{
public class OracleDataSourceFixture
{
[Fact]
public void Constructor_SetsProviderToOracle_WhenConstructed()
{
// Act
var dataSource = new OracleDataSource();

// Assert
Assert.Equal(DataSourceProvider.Oracle, dataSource.Provider);
}

[Theory]
[InlineData("TestService")]
[InlineData(null)]
public void Service_SetsAndGetsValue_WithDifferentInputs(string service)
{
// Arrange
var dataSource = new OracleDataSource();

// Act
dataSource.Service = service;

// Assert
Assert.Equal(service, dataSource.Service);
Assert.Equal(service, dataSource.Properties.GetValue<string>("Service"));
}

[Theory]
[InlineData("TestSID")]
[InlineData(null)]
public void SID_SetsAndGetsValue_WithDifferentInputs(string sid)
{
// Arrange
var dataSource = new OracleDataSource();

// Act
dataSource.SID = sid;

// Assert
Assert.Equal(sid, dataSource.SID);
Assert.Equal(sid, dataSource.Properties.GetValue<string>("SID"));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Reveal.Sdk.Dom.Data;
using Xunit;

namespace Reveal.Sdk.Dom.Tests.Data.DataSources
{
public class PostgreSQLDataSourceFixture
{
[Fact]
public void Constructor_SetsProviderToPostgreSQL_WhenConstructed()
{
// Act
var dataSource = new PostgreSQLDataSource();

// Assert
Assert.Equal(DataSourceProvider.PostgreSQL, dataSource.Provider);
}
}
}
Loading