Skip to content

Commit 811b9a8

Browse files
committed
Added a test for the extracted Theme from the Themes.json file of a DMA
1 parent 4b295cd commit 811b9a8

File tree

5 files changed

+250
-11
lines changed

5 files changed

+250
-11
lines changed

Low Code App Editor_1/Package/PackageInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ public static PackageInfo FromApp()
4646
public static PackageInfo FromApp(App app)
4747
{
4848
var info = PackageInfo.FromApp();
49-
info.DisplayName = $"{app.Name} App Install Pacakge";
50-
info.Name = $"{app.Name} App Install Pacakge";
49+
info.DisplayName = $"{app.Name} App Install Package";
50+
info.Name = $"{app.Name} App Install Package";
5151
return info;
5252
}
5353
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
{
2+
"__type": "Skyline.DataMiner.Web.Common.v1.Dashboards.DMADashboardThemes",
3+
"Themes": [
4+
{
5+
"__type": "Skyline.DataMiner.Web.Common.v1.Dashboards.DMADashboardTheme",
6+
"ID": 1,
7+
"IsDefault": false,
8+
"IsCustom": false,
9+
"ComponentBackgroundColor": "rgb(255,255,255)",
10+
"ComponentThemes": [
11+
{
12+
"__type": "Skyline.DataMiner.Web.Common.v1.Dashboards.DMADashboardComponentTheme",
13+
"Name": "Transparant",
14+
"Inherit": null,
15+
"BackgroundColor": "rgba(238,238,238,0)",
16+
"FontColor": "#000000",
17+
"MarginHorizontal": 5,
18+
"Colors": [
19+
"rgb(76,84,84)",
20+
"rgb(255,113,91)",
21+
"rgb(138,79,255)",
22+
"rgb(30,168,150)",
23+
"rgb(82,63,56)"
24+
],
25+
"MarginVertical": 5,
26+
"PaddingHorizontal": 5,
27+
"PaddingVertical": 5,
28+
"BorderWidth": 1,
29+
"BorderStyle": "none",
30+
"BorderSide": 15,
31+
"BorderRadius": 0,
32+
"BorderColor": "#000000",
33+
"TitleAlignment": "left",
34+
"TitleFontSize": 16,
35+
"TitleFontFamily": "inherit",
36+
"TitleBold": false,
37+
"TitleItalic": false,
38+
"IncludeTitleBorder": false,
39+
"ShadowColor": "#000000",
40+
"ShadowStyle": 0
41+
}
42+
],
43+
"Name": "Kata 19",
44+
"Inherit": null,
45+
"BackgroundColor": "rgb(240,240,240)",
46+
"FontColor": "#000000",
47+
"MarginHorizontal": 5,
48+
"Colors": [
49+
"rgb(76,84,84)",
50+
"rgb(255,113,91)",
51+
"rgb(138,79,255)",
52+
"rgb(30,168,150)",
53+
"rgb(82,63,56)"
54+
],
55+
"MarginVertical": 5,
56+
"PaddingHorizontal": 5,
57+
"PaddingVertical": 5,
58+
"BorderWidth": 1,
59+
"BorderStyle": "none",
60+
"BorderSide": 15,
61+
"BorderRadius": 0,
62+
"BorderColor": "#000000",
63+
"TitleAlignment": "left",
64+
"TitleFontSize": 16,
65+
"TitleFontFamily": "inherit",
66+
"TitleBold": false,
67+
"TitleItalic": false,
68+
"IncludeTitleBorder": false,
69+
"ShadowColor": "#000000",
70+
"ShadowStyle": 0
71+
},
72+
{
73+
"__type": "Skyline.DataMiner.Web.Common.v1.Dashboards.DMADashboardTheme",
74+
"ID": 2,
75+
"IsDefault": false,
76+
"IsCustom": false,
77+
"ComponentBackgroundColor": "rgb(205,205,205)",
78+
"ComponentThemes": [
79+
{
80+
"__type": "Skyline.DataMiner.Web.Common.v1.Dashboards.DMADashboardComponentTheme",
81+
"Name": "Transparant",
82+
"Inherit": null,
83+
"BackgroundColor": "rgba(238,238,238,0)",
84+
"FontColor": "#000000",
85+
"MarginHorizontal": 5,
86+
"Colors": [
87+
"rgb(76,84,84)",
88+
"rgb(255,113,91)",
89+
"rgb(138,79,255)",
90+
"rgb(30,168,150)",
91+
"rgb(82,63,56)"
92+
],
93+
"MarginVertical": 5,
94+
"PaddingHorizontal": 5,
95+
"PaddingVertical": 5,
96+
"BorderWidth": 1,
97+
"BorderStyle": "none",
98+
"BorderSide": 15,
99+
"BorderRadius": 0,
100+
"BorderColor": "#000000",
101+
"TitleAlignment": "left",
102+
"TitleFontSize": 16,
103+
"TitleFontFamily": "inherit",
104+
"TitleBold": false,
105+
"TitleItalic": false,
106+
"IncludeTitleBorder": false,
107+
"ShadowColor": "#000000",
108+
"ShadowStyle": 0
109+
}
110+
],
111+
"Name": "EXTRACT ME PLEASE",
112+
"Inherit": null,
113+
"BackgroundColor": "rgb(240,240,240)",
114+
"FontColor": "#000000",
115+
"MarginHorizontal": 5,
116+
"Colors": [
117+
"rgb(76,84,84)",
118+
"rgb(255,113,91)",
119+
"rgb(138,79,255)",
120+
"rgb(30,168,150)",
121+
"rgb(82,63,56)"
122+
],
123+
"MarginVertical": 5,
124+
"PaddingHorizontal": 5,
125+
"PaddingVertical": 5,
126+
"BorderWidth": 1,
127+
"BorderStyle": "none",
128+
"BorderSide": 15,
129+
"BorderRadius": 0,
130+
"BorderColor": "#000000",
131+
"TitleAlignment": "left",
132+
"TitleFontSize": 16,
133+
"TitleFontFamily": "inherit",
134+
"TitleBold": false,
135+
"TitleItalic": false,
136+
"IncludeTitleBorder": false,
137+
"ShadowColor": "#000000",
138+
"ShadowStyle": 0
139+
}
140+
],
141+
"DefaultThemeID": 0
142+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"__type": "Skyline.DataMiner.Web.Common.v1.Dashboards.DMADashboardThemes",
3+
"Themes": [
4+
{
5+
"__type": "Skyline.DataMiner.Web.Common.v1.Dashboards.DMADashboardTheme",
6+
"ID": 2,
7+
"IsDefault": false,
8+
"IsCustom": false,
9+
"ComponentBackgroundColor": "rgb(205,205,205)",
10+
"ComponentThemes": [
11+
{
12+
"__type": "Skyline.DataMiner.Web.Common.v1.Dashboards.DMADashboardComponentTheme",
13+
"Name": "Transparant",
14+
"Inherit": null,
15+
"BackgroundColor": "rgba(238,238,238,0)",
16+
"FontColor": "#000000",
17+
"MarginHorizontal": 5,
18+
"Colors": [
19+
"rgb(76,84,84)",
20+
"rgb(255,113,91)",
21+
"rgb(138,79,255)",
22+
"rgb(30,168,150)",
23+
"rgb(82,63,56)"
24+
],
25+
"MarginVertical": 5,
26+
"PaddingHorizontal": 5,
27+
"PaddingVertical": 5,
28+
"BorderWidth": 1,
29+
"BorderStyle": "none",
30+
"BorderSide": 15,
31+
"BorderRadius": 0,
32+
"BorderColor": "#000000",
33+
"TitleAlignment": "left",
34+
"TitleFontSize": 16,
35+
"TitleFontFamily": "inherit",
36+
"TitleBold": false,
37+
"TitleItalic": false,
38+
"IncludeTitleBorder": false,
39+
"ShadowColor": "#000000",
40+
"ShadowStyle": 0
41+
}
42+
],
43+
"Name": "EXTRACT ME PLEASE",
44+
"Inherit": null,
45+
"BackgroundColor": "rgb(240,240,240)",
46+
"FontColor": "#000000",
47+
"MarginHorizontal": 5,
48+
"Colors": [
49+
"rgb(76,84,84)",
50+
"rgb(255,113,91)",
51+
"rgb(138,79,255)",
52+
"rgb(30,168,150)",
53+
"rgb(82,63,56)"
54+
],
55+
"MarginVertical": 5,
56+
"PaddingHorizontal": 5,
57+
"PaddingVertical": 5,
58+
"BorderWidth": 1,
59+
"BorderStyle": "none",
60+
"BorderSide": 15,
61+
"BorderRadius": 0,
62+
"BorderColor": "#000000",
63+
"TitleAlignment": "left",
64+
"TitleFontSize": 16,
65+
"TitleFontFamily": "inherit",
66+
"TitleBold": false,
67+
"TitleItalic": false,
68+
"IncludeTitleBorder": false,
69+
"ShadowColor": "#000000",
70+
"ShadowStyle": 0
71+
}
72+
],
73+
"DefaultThemeID": 0
74+
}
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,37 @@
11
namespace Low_Code_App_Editor_1.Controllers.Tests
22
{
33
using System.IO;
4+
using System.Linq;
5+
46
using Low_Code_App_Editor_1.Json;
57
using Microsoft.VisualStudio.TestTools.UnitTesting;
68
using Newtonsoft.Json;
9+
using Newtonsoft.Json.Linq;
10+
711
using Skyline.DataMiner.Web.Common.v1.Dashboards;
812

913
[TestClass]
1014
public class ExportControllerTests
1115
{
1216
[TestMethod]
13-
public void SerializeThemes()
17+
public void ExtractThemeFromFile()
1418
{
15-
var themesRaw = File.ReadAllText(@"C:\Skyline DataMiner\dashboards\Themes.json");
16-
var themes = JsonConvert.DeserializeObject<DMADashboardThemes>(themesRaw);
19+
// Original themes
20+
var themesJson = JObject.Parse(File.ReadAllText(@"CompanionFiles\Themes.json"));
21+
var allThemes = themesJson["Themes"] as JArray;
22+
23+
// Create a copy of the themes object, clear all the themes out.
24+
var usedThemesJson = themesJson.DeepClone();
25+
var usedThemesArray = usedThemesJson["Themes"] as JArray;
26+
usedThemesArray.Clear();
27+
28+
// Add the theme called "EXTRACT ME PLEASE"
29+
var usedTheme = allThemes.First(t => t["Name"].Value<string>() == "EXTRACT ME PLEASE");
30+
usedThemesArray.Add(usedTheme);
1731

18-
var usedThemesFile = JsonConvert.SerializeObject(
19-
new DMADashboardThemes
20-
{
21-
Themes = (DMADashboardTheme[])themes.Themes.Clone(),
22-
}, new TypeConverter());
32+
var correct = JObject.Parse(File.ReadAllText(@"CompanionFiles\Themes_Extracted.json"));
2333

24-
Assert.IsTrue(true);
34+
Assert.IsTrue(JToken.DeepEquals(usedThemesJson, correct));
2535
}
2636
}
2737
}

Low Code App Editor_1Tests/Low Code App Editor_1Tests.csproj

+13
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,17 @@
2727
</Reference>
2828
</ItemGroup>
2929

30+
<ItemGroup>
31+
<Folder Include="CompanionFiles\" />
32+
</ItemGroup>
33+
34+
<ItemGroup>
35+
<None Update="CompanionFiles\Themes.json">
36+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
37+
</None>
38+
<None Update="CompanionFiles\Themes_Extracted.json">
39+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
40+
</None>
41+
</ItemGroup>
42+
3043
</Project>

0 commit comments

Comments
 (0)