-
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 #264 from RevealBi/unit-test/sparkline-vs-dataspec
Create UTs for SparklineVisualizationDataSpec class
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 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
66 changes: 66 additions & 0 deletions
66
....Sdk.Dom.Tests/Visualizations/VisualizationSpecs/SparklineVisualizationDataSpecFixture.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,66 @@ | ||
using Newtonsoft.Json.Linq; | ||
using Reveal.Sdk.Dom.Core.Constants; | ||
using Reveal.Sdk.Dom.Visualizations; | ||
using Reveal.Sdk.Dom.Visualizations.VisualizationSpecs; | ||
using System.Collections.Generic; | ||
using Xunit; | ||
|
||
namespace Reveal.Sdk.Dom.Tests.Visualizations.VisualizationSpecs | ||
{ | ||
public class SparklineVisualizationDataSpecFixture | ||
{ | ||
[Fact] | ||
public void Constructor_FieldsHaveDefaultValue() | ||
{ | ||
// Act | ||
var sparklineVSDataSpec = new SparklineVisualizationDataSpec(); | ||
|
||
// Assert | ||
Assert.Equal(SchemaTypeNames.SparklineVisualizationDataSpecType, sparklineVSDataSpec.SchemaTypeName); | ||
Assert.Equal(IndicatorVisualizationType.LastMonths, sparklineVSDataSpec.IndicatorType); | ||
} | ||
|
||
[Fact] | ||
public void ToJsonString_CreateCorrectJsonString_WithoutCondition() | ||
{ | ||
// Arrange | ||
var expectedJson = """ | ||
{ | ||
"_type": "BubbleVisualizationDataSpecType", | ||
"NumberOfPeriods": 3, | ||
"ShowIndicator": false, | ||
"IndicatorType": "YearToDatePreviousYear", | ||
"Date": { | ||
"_type": "DimensionColumnSpecType" | ||
}, | ||
"Value": [], | ||
"AdHocFields": 12, | ||
"FormatVersion": 2, | ||
"AdHocExpandedElements": [], | ||
"Rows": [] | ||
} | ||
"""; | ||
var sparklineVSDataSpec = new SparklineVisualizationDataSpec() | ||
{ | ||
AdHocExpandedElements = new List<AdHocExpandedElement>(), | ||
AdHocFields = 12, | ||
Date = new DimensionColumn(), | ||
FormatVersion = 2, | ||
IndicatorType = IndicatorVisualizationType.YearToDatePreviousYear, | ||
NumberOfPeriods =3, | ||
Rows = new List<DimensionColumn>(), | ||
SchemaTypeName = SchemaTypeNames.BubbleVisualizationDataSpecType, | ||
ShowIndicator = false, | ||
Value = new List<MeasureColumn>() | ||
}; | ||
|
||
// Act | ||
var actualJson = sparklineVSDataSpec.ToJsonString(); | ||
var expectedJObject = JObject.Parse(expectedJson); | ||
var actualJObject = JObject.Parse(actualJson); | ||
|
||
// Assert | ||
Assert.Equal(expectedJObject, actualJObject); | ||
} | ||
} | ||
} |