Skip to content

Commit

Permalink
Merge pull request #266 from RevealBi/unit-test/single-gauge-vs-dataspec
Browse files Browse the repository at this point in the history
Create UTs for SingleGaugeVisualizationDataSpec class
  • Loading branch information
hainv-ohio authored Jan 9, 2025
2 parents 82281db + 6906315 commit 341eff1
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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 SingleGaugeVisualizationDataSpecFixture
{
[Fact]
public void Constructor_FieldsHaveDefaultValue_WithoutParameters()
{
// Act
var singleGaugeVSDataSpec = new SingleGaugeVisualizationDataSpec();

// Assert
Assert.Equal(SchemaTypeNames.SingleGaugeVisualizationDataSpecType, singleGaugeVSDataSpec.SchemaTypeName);
}

[Fact]
public void ToJsonString_CreateCorrectJsonString_WithoutCondition()
{
// Arrange
var expectedJson = """
{
"_type": "SingleGaugeVisualizationDataSpecType",
"Label": {
"_type": "DimensionColumnSpecType"
},
"Value": []
}
""";
var singleGaugeVSDataSpec = new SingleGaugeVisualizationDataSpec()
{
Label = new DimensionColumn(),
Value = new List<MeasureColumn>()
};

// Act
var actualJson = singleGaugeVSDataSpec.ToJsonString();
var expectedJObject = JObject.Parse(expectedJson);
var actualJObject = JObject.Parse(actualJson);

// Assert
Assert.Equal(expectedJObject, actualJObject);
}
}
}

0 comments on commit 341eff1

Please sign in to comment.