-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* first draft of new file structure * update readme * minor fixes * improve code coverage * Create SECURITY.md (#25) * Create SECURITY.md --------- Signed-off-by: wolframhaussig <13997737+wolframhaussig@users.noreply.github.com> * added AbstractThemePlugin to make plugin implementations more error proof (#29) * Add link to JSON schema (only works after merging the PR) * removed the (possibly wrong) reference to a "V2" * removed obsolete code --------- Signed-off-by: wolframhaussig <13997737+wolframhaussig@users.noreply.github.com>
- Loading branch information
1 parent
3f842bc
commit 86decfc
Showing
8 changed files
with
616 additions
and
145 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,181 @@ | ||
using System.Drawing; | ||
using System.Drawing; | ||
using Microsoft.Extensions.Logging; | ||
using TestProject.Properties; | ||
using WinFormsThemes.Extensions; | ||
using WinFormsThemes.Themes; | ||
|
||
namespace TestProject | ||
{ | ||
[TestClass] | ||
public class FileThemeTest | ||
public class FileThemeTest : AbstractTestClass | ||
{ | ||
[TestMethod] | ||
public void LoadShouldNotThrow_MissingCapabilities() | ||
{ | ||
FileTheme? theme = FileTheme.Load(Resources.MISSING_CAPS); | ||
FileTheme? theme = FileTheme.Load(Resources.MISSING_CAPS, getLogger()); | ||
Assert.IsNull(theme); | ||
} | ||
|
||
[TestMethod] | ||
public void LoadShouldNotThrow_MissingColors() | ||
{ | ||
FileTheme? theme = FileTheme.Load(Resources.MISSING_COLORS); | ||
FileTheme? theme = FileTheme.Load(Resources.MISSING_COLORS, getLogger()); | ||
Assert.IsNotNull(theme); | ||
Assert.AreEqual(SystemColors.Control, theme.BackgroundColor); | ||
} | ||
|
||
[TestMethod] | ||
public void LoadShouldNotThrow_MissingName() | ||
{ | ||
FileTheme? theme = FileTheme.Load(Resources.MISSING_NAME); | ||
FileTheme? theme = FileTheme.Load(Resources.MISSING_NAME, getLogger()); | ||
Assert.IsNull(theme); | ||
} | ||
|
||
[TestMethod] | ||
public void LoadShouldNotThrow_NonJson() | ||
{ | ||
FileTheme? theme = FileTheme.Load("abc"); | ||
FileTheme? theme = FileTheme.Load("abc", getLogger()); | ||
Assert.IsNull(theme); | ||
} | ||
|
||
[TestMethod] | ||
public void LoadVersionedSimple() | ||
{ | ||
FileTheme? theme = FileTheme.Load(@" | ||
{ | ||
'name': 'theme-name', | ||
'capabilities': ['DarkMode', 'HighContrast'], | ||
'version': 3, | ||
'variables': { | ||
}, | ||
'colors': { | ||
'backColor': '#082a56', | ||
'foreColor': '#082a56', | ||
'controls': { | ||
'backColor': '#082a56', | ||
'foreColor': '#082a56' | ||
} | ||
} | ||
}".Replace("'", "\"", StringComparison.Ordinal), getLogger()); | ||
Assert.IsNotNull(theme); | ||
} | ||
|
||
[TestMethod] | ||
public void LoadVersionedWithVariable() | ||
{ | ||
FileTheme? theme = FileTheme.Load(@" | ||
{ | ||
'name': 'theme-name', | ||
'capabilities': ['DarkMode', 'HighContrast'], | ||
'version': 3, | ||
'variables': { | ||
'backColor': '#082a56', | ||
'foreColor': '#082a57' | ||
}, | ||
'colors': { | ||
'backColor': 'backColor', | ||
'foreColor': 'foreColor', | ||
'controls': { | ||
'backColor': 'backColor', | ||
'foreColor': 'foreColor' | ||
} | ||
} | ||
}".Replace("'", "\"", StringComparison.CurrentCulture), getLogger()); | ||
Assert.IsNotNull(theme); | ||
Assert.AreEqual("#082a56".ToColor(), theme.ControlBackColor); | ||
Assert.AreEqual("#082a57".ToColor(), theme.ControlForeColor); | ||
} | ||
|
||
[TestMethod] | ||
public void LoadVersionedInvalidSchema() | ||
{ | ||
FileTheme? theme = FileTheme.Load(@" | ||
{ | ||
'name': 'theme-name', | ||
'capabilities': ['DarkMode', 'HighContrast'], | ||
'version': 3, | ||
'variables': { | ||
} | ||
}".Replace("'", "\"", StringComparison.CurrentCulture), getLogger()); | ||
Assert.IsNull(theme); | ||
} | ||
|
||
[TestMethod] | ||
public void LoadVersionedDefaultValue() | ||
{ | ||
FileTheme? theme = FileTheme.Load(@" | ||
{ | ||
'name': 'theme-name', | ||
'capabilities': ['DarkMode', 'HighContrast'], | ||
'version': 3, | ||
'variables': { | ||
}, | ||
'colors': { | ||
'backColor': '#082a56', | ||
'foreColor': '#082a56', | ||
'controls': { | ||
'backColor': '#082a56', | ||
'foreColor': '#082a56' | ||
} | ||
} | ||
}".Replace("'", "\"", StringComparison.CurrentCulture), getLogger()); | ||
Assert.IsNotNull(theme); | ||
Assert.AreEqual("#082a56".ToColor(), theme.TableBackColor); | ||
} | ||
|
||
[TestMethod] | ||
public void LoadVersionedInvalidColorOrVariable() | ||
{ | ||
FileTheme? theme = FileTheme.Load(@" | ||
{ | ||
'name': 'theme-name', | ||
'capabilities': ['DarkMode', 'HighContrast'], | ||
'version': 3, | ||
'variables': { | ||
}, | ||
'colors': { | ||
'backColor': 'unknown', | ||
'foreColor': '#082a56', | ||
'controls': { | ||
'backColor': '#082a56', | ||
'foreColor': '#082a56' | ||
} | ||
} | ||
}".Replace("'", "\"", StringComparison.CurrentCulture), getLogger()); | ||
Assert.IsNull(theme); | ||
} | ||
|
||
[TestMethod] | ||
public void LoadVersionedSkipEmptyCapabilities() | ||
{ | ||
FileTheme? theme = FileTheme.Load(@" | ||
{ | ||
'name': 'theme-name', | ||
'capabilities': ['DarkMode', 'HighContrast', ''], | ||
'version': 3, | ||
'variables': { | ||
}, | ||
'colors': { | ||
'backColor': '#082a56', | ||
'foreColor': '#082a56', | ||
'controls': { | ||
'backColor': '#082a56', | ||
'foreColor': '#082a56' | ||
} | ||
} | ||
}".Replace("'", "\"", StringComparison.Ordinal), getLogger()); | ||
Assert.IsNotNull(theme); | ||
Assert.AreEqual(0, theme.AdvancedCapabilities.Count); | ||
} | ||
|
||
private ILogger getLogger() | ||
{ | ||
return new Logger<FileThemeTest>(LoggerFactory); | ||
} | ||
} | ||
} | ||
} |
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
Oops, something went wrong.