Skip to content

Commit

Permalink
Add UT for ToJsonString method
Browse files Browse the repository at this point in the history
  • Loading branch information
vulh-infragistics committed Jan 7, 2025
1 parent 3fcf9c2 commit ff0bb93
Showing 1 changed file with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Reveal.Sdk.Dom.Core.Constants;
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
Expand All @@ -18,5 +20,48 @@ public void Constructor_FieldsHaveDefaultValue_WithoutParameters()
Assert.Equal(KpiGoalPeriod.YearToDate, indicatorTargetVSDataSpec.DateFilterType);
Assert.Equal(SchemaTypeNames.IndicatorTargetVisualizationDataSpecType, indicatorTargetVSDataSpec.SchemaTypeName);
}

[Fact]
public void ToJsonString_CreateCorrectJsonString_WithoutCondition()
{
// Arrange
var expectedJson = """
{
"_type": "AssetVisualizationSettingsType",
"Target": [],
"DateFilterType": "PreviousMonth",
"CustomDateRange": {},
"Date": {
"_type": "DimensionColumnSpecType"
},
"Value": [],
"AdHocFields": 11,
"FormatVersion": 2,
"AdHocExpandedElements": [],
"Rows": []
}
""";
var indicatorTargetVSDataSpec = new IndicatorTargetVisualizationDataSpec()
{
SchemaTypeName = SchemaTypeNames.AssetVisualizationSettingsType,
Value = new List<MeasureColumn>(),
AdHocExpandedElements = new List<AdHocExpandedElement>(),
AdHocFields = 11,
CustomDateRange = new DateRange(),
Date = new DimensionColumn(),
DateFilterType = KpiGoalPeriod.PreviousMonth,
FormatVersion = 2,
Rows = new List<DimensionColumn>(),
Target = new List<MeasureColumn>(),
};

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

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

0 comments on commit ff0bb93

Please sign in to comment.