-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes: * ApexCharts.NET Test * FormatJson Option * Test Project * small fixes
- Loading branch information
Showing
15 changed files
with
174 additions
and
27 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
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
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
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,8 @@ | ||
namespace Tolbxela.ApexCharts | ||
{ | ||
public enum StrokeCurve | ||
{ | ||
smooth, | ||
straight | ||
} | ||
} |
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
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
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
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
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
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
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
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
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
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,77 @@ | ||
using System; | ||
using Newtonsoft.Json; | ||
using Tolbxela.ApexCharts; | ||
using Xunit; | ||
|
||
namespace Test | ||
{ | ||
public class ApexChartTests | ||
{ | ||
const string ChartName = "Chart"; | ||
const string Selector = "#Selector"; | ||
|
||
public ApexChartTests() | ||
{ | ||
} | ||
|
||
[Fact] | ||
public void ApexChartTest_NotNull() | ||
{ | ||
var chart = new ApexChart(ChartName, Selector, null, formatJson: false); | ||
Assert.NotNull(chart); | ||
} | ||
|
||
[Fact] | ||
public void ApexChartTest_Json() | ||
{ | ||
var chart = new ApexChart(ChartName, Selector, null, formatJson: false); | ||
var json = chart.ToString(); | ||
Assert.False(string.IsNullOrWhiteSpace(json)); | ||
} | ||
|
||
[Fact] | ||
public void ApexChartTest_NullOptions() | ||
{ | ||
var chart = new ApexChart(ChartName, Selector, null, formatJson: false); | ||
var chartJson = chart.ToString(); | ||
var options = "null"; | ||
var chartSample = $"var {ChartName} = new ApexCharts(document.querySelector(\"{Selector}\"), {options});" + Environment.NewLine + | ||
$"{ChartName}.render();"; | ||
|
||
Assert.Equal(chartSample, chartJson); | ||
} | ||
|
||
[Fact] | ||
public void ApexChartTest_EmptyOptions() | ||
{ | ||
var options = new ChartOptions(); | ||
|
||
var jsonOptions = JsonConvert.SerializeObject( | ||
options, | ||
Formatting.None, | ||
new JsonSerializerSettings | ||
{ | ||
NullValueHandling = NullValueHandling.Ignore | ||
} | ||
); | ||
|
||
var jsonOptionsSample = "{\"chart\":{}}"; | ||
|
||
Assert.Equal(jsonOptionsSample, jsonOptions); | ||
} | ||
|
||
[Fact] | ||
public void ApexChartTest_EmptyChart() | ||
{ | ||
var options = new ChartOptions(); | ||
|
||
var chart = new ApexChart(ChartName, Selector, options, formatJson: false); | ||
var chartJson = chart.ToString(); | ||
var jsonOptionsSample = "{\"chart\":{\"id\":\"" + ChartName + "\"}}"; | ||
var chartSample = $"var {ChartName} = new ApexCharts(document.querySelector(\"{Selector}\"), {jsonOptionsSample});" + Environment.NewLine + | ||
$"{ChartName}.render();"; | ||
|
||
Assert.Equal(chartSample, chartJson); | ||
} | ||
} | ||
} |
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,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.2</TargetFramework> | ||
|
||
<IsPackable>false</IsPackable> | ||
|
||
<Authors>Tolbxela</Authors> | ||
|
||
<Copyright>Tolbxela © 2019</Copyright> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="coverlet.collector" Version="1.0.1"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.msbuild" Version="2.6.3"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" /> | ||
<PackageReference Include="xunit" Version="2.4.0" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Code\ApexCharts.NET.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |