Skip to content

Commit 2d6974a

Browse files
xml serialization issue fix (#189)
* xml serialization issue fix * reference config files for .NET (instead of Java) and add unit tests --------- Co-authored-by: Anshoo Arora <[email protected]>
1 parent 7109387 commit 2d6974a

File tree

4 files changed

+90
-1
lines changed

4 files changed

+90
-1
lines changed

ExtentReports.Tests/Reporter/SparkReporterTest.cs

+23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using AventStack.ExtentReports.Reporter;
2+
using AventStack.ExtentReports.Reporter.Config;
23
using NUnit.Framework;
34
using System;
45
using System.IO;
@@ -135,5 +136,27 @@ public void SparkOffline()
135136
Assert.True(File.Exists("extent/" + Scripts));
136137
Assert.True(File.Exists("extent/" + Stylesheet));
137138
}
139+
140+
[Test]
141+
public void SparkXMLConfig()
142+
{
143+
var xmlConfigPath = Path.Combine(@"..\..\..\..\", @"config\spark-config.xml");
144+
var spark = new ExtentSparkReporter("Spark.html");
145+
spark.LoadXMLConfig(xmlConfigPath);
146+
Assert.AreEqual(spark.Config.Theme, Theme.Standard);
147+
Assert.AreEqual(spark.Config.DocumentTitle, "Extent Framework");
148+
Assert.AreEqual(spark.Config.Protocol, Protocol.HTTPS);
149+
}
150+
151+
[Test]
152+
public void SparkJSONConfig()
153+
{
154+
var xmlConfigPath = Path.Combine(@"..\..\..\..\", @"config\spark-config.json");
155+
var spark = new ExtentSparkReporter("Spark.html");
156+
spark.LoadJSONConfig(xmlConfigPath);
157+
Assert.AreEqual(spark.Config.Theme, Theme.Standard);
158+
Assert.AreEqual(spark.Config.DocumentTitle, "Extent Framework");
159+
Assert.AreEqual(spark.Config.Protocol, Protocol.HTTPS);
160+
}
138161
}
139162
}

ExtentReports/Reporter/Config/Theme.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{
33
public enum Theme
44
{
5-
Standard, Dark
5+
Standard,
6+
Dark
67
}
78
}

config/spark-config.json

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"theme": "Standard",
3+
"encoding": "utf-8",
4+
"protocol": "HTTPS",
5+
"timelineEnabled": false,
6+
"offlineMode": true,
7+
"thumbnailForBase64": false,
8+
"documentTitle": "Extent Framework",
9+
"reportName": "ExtentReports",
10+
"timeStampFormat": "MMM dd, yyyy HH:mm:ss a",
11+
"js": "",
12+
"css": ""
13+
}

config/spark-config.xml

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
4+
<!-- report theme -->
5+
<!-- Standard, Dark -->
6+
<theme>Standard</theme>
7+
8+
<!-- document encoding -->
9+
<!-- defaults to UTF-8 -->
10+
<encoding>UTF-8</encoding>
11+
12+
<!-- protocol for script and stylesheets -->
13+
<!-- defaults to https -->
14+
<!-- HTTP, HTTPS -->
15+
<protocol>HTTPS</protocol>
16+
17+
<!-- offline report -->
18+
<timelineEnabled>true</timelineEnabled>
19+
20+
<!-- offline report -->
21+
<enableOfflineMode>false</enableOfflineMode>
22+
23+
<!-- use thumbnails for base64 images -->
24+
<!-- this may slowdown viewing tests -->
25+
<thumbnailForBase64>false</thumbnailForBase64>
26+
27+
<!-- title of the document -->
28+
<documentTitle>Extent Framework</documentTitle>
29+
30+
<!-- report name - displayed at top-nav -->
31+
<reportName>Build 1</reportName>
32+
33+
<!-- timestamp format -->
34+
<timeStampFormat>MMM dd, yyyy HH:mm:ss</timeStampFormat>
35+
36+
<!-- custom javascript -->
37+
<scripts>
38+
<![CDATA[
39+
$(document).ready(function() {
40+
41+
});
42+
]]>
43+
</scripts>
44+
45+
<!-- custom styles -->
46+
<styles>
47+
<![CDATA[
48+
49+
]]>
50+
</styles>
51+
52+
</configuration>

0 commit comments

Comments
 (0)