-
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 #100 from RevealBi/develop
Add unit tests
- Loading branch information
Showing
56 changed files
with
2,572 additions
and
195 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
126 changes: 126 additions & 0 deletions
126
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,126 @@ | ||
using Reveal.Sdk.Dom.Data; | ||
using System; | ||
using Xunit; | ||
|
||
namespace Reveal.Sdk.Dom.Tests.Data | ||
{ | ||
public class DataSourceItemFactoryFixture | ||
{ | ||
[Fact] | ||
public void Create_ReturnDataSourceItem_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<MicrosoftSqlServerDataSource>(result.DataSource); | ||
} | ||
|
||
[Fact] | ||
public void Create_ReturnDataSourceItem_WithCustomDataSource() | ||
{ | ||
// Arrange | ||
var factory = new DataSourceItemFactory(); | ||
var type = DataSourceType.MicrosoftSqlServer; | ||
var id = "1"; | ||
var title = "Test Title"; | ||
var dataSource = new DataSource(); | ||
|
||
// Act | ||
var result = factory.Create(type, id, title, dataSource); | ||
|
||
// 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.NotSame(dataSource, result.DataSource); | ||
Assert.IsType<MicrosoftSqlServerDataSource>(result.DataSource); | ||
} | ||
|
||
[Fact] | ||
public void Create_ReturnDataSourceItem_WithCustomSubtitle() | ||
{ | ||
// Arrange | ||
var factory = new DataSourceItemFactory(); | ||
var type = DataSourceType.MicrosoftSqlServer; | ||
var id = "1"; | ||
var title = "Test Title"; | ||
var subTitle = "Test Subtitle"; | ||
|
||
// Act | ||
var result = factory.Create(type, id, title, subTitle); | ||
|
||
// 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.IsType<MicrosoftSqlServerDataSource>(result.DataSource); | ||
} | ||
|
||
[Fact] | ||
public void Create_ReturnDataSourceItem_WithCustomDataSourceAndSubTitle() | ||
{ | ||
// 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.NotSame(dataSource, result.DataSource); | ||
Assert.IsType<MicrosoftSqlServerDataSource>(result.DataSource); | ||
} | ||
|
||
[Fact] | ||
public void Create_ThrowNotImplementedException_WhenUnknownType() | ||
{ | ||
// Arrange | ||
var factory = new DataSourceItemFactory(); | ||
var type = (DataSourceType)99; | ||
var id = "3"; | ||
var title = "Test Title"; | ||
var subtitle = "Test Subtitle"; | ||
var dataSource = new DataSource(); | ||
|
||
// Act & Assert | ||
Assert.Throws<NotImplementedException>(() => factory.Create(type, id, title)); | ||
Assert.Throws<NotImplementedException>(() => factory.Create(type, id, title, dataSource)); | ||
Assert.Throws<NotImplementedException>(() => factory.Create(type, id, title, subtitle)); | ||
Assert.Throws<NotImplementedException>(() => factory.Create(type, id, title, subtitle, dataSource)); | ||
} | ||
} | ||
} |
Oops, something went wrong.