forked from ConfusedPolarBear/intro-skipper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4e84d4
commit cc01c76
Showing
6 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
ConfusedPolarBear.Plugin.IntroSkipper.Tests/TestWarnings.cs
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,34 @@ | ||
namespace ConfusedPolarBear.Plugin.IntroSkipper.Tests; | ||
|
||
using Xunit; | ||
|
||
public class TestFlags | ||
{ | ||
[Fact] | ||
public void TestEmptyFlagSerialization() | ||
{ | ||
WarningManager.Clear(); | ||
Assert.Equal("None", WarningManager.GetWarnings()); | ||
} | ||
|
||
[Fact] | ||
public void TestSingleFlagSerialization() | ||
{ | ||
WarningManager.Clear(); | ||
WarningManager.SetFlag(PluginWarning.UnableToAddSkipButton); | ||
Assert.Equal("UnableToAddSkipButton", WarningManager.GetWarnings()); | ||
} | ||
|
||
[Fact] | ||
public void TestDoubleFlagSerialization() | ||
{ | ||
WarningManager.Clear(); | ||
WarningManager.SetFlag(PluginWarning.UnableToAddSkipButton); | ||
WarningManager.SetFlag(PluginWarning.InvalidChromaprintFingerprint); | ||
WarningManager.SetFlag(PluginWarning.InvalidChromaprintFingerprint); | ||
|
||
Assert.Equal( | ||
"UnableToAddSkipButton, InvalidChromaprintFingerprint", | ||
WarningManager.GetWarnings()); | ||
} | ||
} |
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
64 changes: 64 additions & 0 deletions
64
ConfusedPolarBear.Plugin.IntroSkipper/Data/PluginWarning.cs
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,64 @@ | ||
namespace ConfusedPolarBear.Plugin.IntroSkipper; | ||
|
||
using System; | ||
|
||
/// <summary> | ||
/// Support bundle warning. | ||
/// </summary> | ||
[Flags] | ||
public enum PluginWarning | ||
{ | ||
/// <summary> | ||
/// No warnings have been added. | ||
/// </summary> | ||
None = 0, | ||
|
||
/// <summary> | ||
/// Attempted to add skip button to web interface, but was unable to. | ||
/// </summary> | ||
UnableToAddSkipButton = 1, | ||
|
||
/// <summary> | ||
/// At least one media file on the server was unable to be fingerprinted by Chromaprint. | ||
/// </summary> | ||
InvalidChromaprintFingerprint = 2, | ||
|
||
/// <summary> | ||
/// The version of ffmpeg installed on the system is not compatible with the plugin. | ||
/// </summary> | ||
IncompatibleFFmpegBuild = 4, | ||
} | ||
|
||
/// <summary> | ||
/// Warning manager. | ||
/// </summary> | ||
public static class WarningManager | ||
{ | ||
private static PluginWarning warnings; | ||
|
||
/// <summary> | ||
/// Set warning. | ||
/// </summary> | ||
/// <param name="warning">Warning.</param> | ||
public static void SetFlag(PluginWarning warning) | ||
{ | ||
warnings |= warning; | ||
} | ||
|
||
/// <summary> | ||
/// Clear warnings. | ||
/// </summary> | ||
public static void Clear() | ||
{ | ||
warnings = PluginWarning.None; | ||
} | ||
|
||
/// <summary> | ||
/// Get warnings. | ||
/// </summary> | ||
/// <returns>Warnings.</returns> | ||
public static string GetWarnings() | ||
{ | ||
return warnings.ToString(); | ||
} | ||
} |
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