-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from RevealBi/dsi-refactor
refactored parameter order for DSI factory and the DSI classes
- Loading branch information
Showing
12 changed files
with
127 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/Reveal.Sdk.Dom.Tests/Data/DataSourceItemFactoryFixture.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
using Reveal.Sdk.Dom.Data; | ||
using System; | ||
using Xunit; | ||
|
||
namespace Reveal.Sdk.Dom.Tests.Data | ||
{ | ||
public class DataSourceItemFactoryFixture | ||
{ | ||
[Fact] | ||
public void Create_ShouldReturnDataSourceItem_WithDefaultDataSource() | ||
{ | ||
// Arrange | ||
var factory = new DataSourceItemFactory(); | ||
var type = DataSourceType.MicrosoftSqlServer; | ||
var id = "1"; | ||
var title = "Test Title"; | ||
|
||
// Act | ||
var result = factory.Create(type, id, title); | ||
|
||
// Assert | ||
Assert.NotNull(result); | ||
Assert.IsType<MicrosoftSqlServerDataSourceItem>(result); | ||
Assert.Equal(id, result.Id); | ||
Assert.Equal(title, result.Title); | ||
Assert.Null(result.Subtitle); | ||
Assert.NotNull(result.DataSource); | ||
Assert.IsType<DataSource>(result.DataSource); | ||
} | ||
|
||
[Fact] | ||
public void Create_ShouldReturnDataSourceItem_WithCustomDataSource() | ||
{ | ||
// Arrange | ||
var factory = new DataSourceItemFactory(); | ||
var type = DataSourceType.MicrosoftSqlServer; | ||
var id = "2"; | ||
var title = "Test Title"; | ||
var subtitle = "Test Subtitle"; | ||
var dataSource = new DataSource() | ||
{ | ||
Id = "CustomId", | ||
Title = "Custom Title", | ||
Subtitle = "Custom Subtitle", | ||
}; | ||
|
||
// Act | ||
var result = factory.Create(type, id, title, subtitle, dataSource); | ||
|
||
// Assert | ||
Assert.NotNull(result); | ||
Assert.IsType<MicrosoftSqlServerDataSourceItem>(result); | ||
Assert.Equal(id, result.Id); | ||
Assert.Equal(title, result.Title); | ||
Assert.Equal(subtitle, result.Subtitle); | ||
Assert.NotNull(result.DataSource); | ||
Assert.Same(dataSource, result.DataSource); | ||
} | ||
|
||
[Fact] | ||
public void Create_ShouldThrowNotImplementedException_WhenUnknownType() | ||
{ | ||
// Arrange | ||
var factory = new DataSourceItemFactory(); | ||
var type = (DataSourceType)99; | ||
var id = "3"; | ||
var title = "Test Title"; | ||
|
||
// Act & Assert | ||
Assert.Throws<NotImplementedException>(() => factory.Create(type, id, title)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/Reveal.Sdk.Dom/Data/Interfaces/IDataSourceItemFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Reveal.Sdk.Dom.Data | ||
{ | ||
public interface IDataSourceItemFactory | ||
{ | ||
DataSourceItem Create(DataSourceType type, string id, string title); | ||
|
||
DataSourceItem Create(DataSourceType type, string id, string title, string subtitle); | ||
|
||
DataSourceItem Create(DataSourceType type, string id, string title, DataSource dataSource); | ||
|
||
DataSourceItem Create(DataSourceType type, string id, string title, string subtitle, DataSource dataSource); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters