-
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 #170 from RevealBi/unit-test/icategory-extension
Create unit tests for ICategoryExtensions class
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/Reveal.Sdk.Dom.Tests/Visualizations/Extensions/ICategoryExtensionsFixture.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,52 @@ | ||
using Moq; | ||
using Reveal.Sdk.Dom.Visualizations; | ||
using Xunit; | ||
|
||
namespace Reveal.Sdk.Dom.Tests.Visualizations.Extensions | ||
{ | ||
public class ICategoryExtensionsFixture | ||
{ | ||
[Fact] | ||
public void SetCategory_UpdateCategory_WithFieldName() | ||
{ | ||
// Arrange | ||
var visualization = new MockICategory(); | ||
var fieldName = "TestField"; | ||
var expectedCategory = new DimensionColumn() | ||
{ | ||
DataField = new TextDataField(fieldName) | ||
}; | ||
|
||
// Act | ||
visualization.SetCategory(fieldName); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedCategory, visualization.Category); | ||
} | ||
|
||
[Fact] | ||
public void SetCategory_UpdateCategory_WithDimensionDataField() | ||
{ | ||
// Arrange | ||
var visualization = new MockICategory(); | ||
var fieldName = "TestField"; | ||
var mockDimensionDataField = new Mock<DimensionDataField>(fieldName); | ||
var field = mockDimensionDataField.Object; | ||
var expectedCategory = new DimensionColumn() | ||
{ | ||
DataField = field | ||
}; | ||
|
||
// Act | ||
visualization.SetCategory(field); | ||
|
||
// Assert | ||
Assert.Equivalent(expectedCategory, visualization.Category); | ||
} | ||
|
||
private class MockICategory : ICategory | ||
{ | ||
public DimensionColumn Category { get; set; } | ||
} | ||
} | ||
} |