-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Support static methods for commands (fix #2)
- Loading branch information
Showing
2 changed files
with
52 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using FakeItEasy; | ||
using NUnit.Framework; | ||
using VampireCommandFramework; | ||
|
||
namespace VCF.Tests; | ||
|
||
public class StaticCommandsTests | ||
{ | ||
[SetUp] | ||
public void Setup() | ||
{ | ||
Log.Instance = new BepInEx.Logging.ManualLogSource("Test"); | ||
CommandRegistry.Reset(); | ||
} | ||
|
||
[Test] | ||
public void Static_Class_Static_Method_Command() | ||
{ | ||
CommandRegistry.RegisterCommandType(typeof(StaticClassTestCommands)); | ||
Assert.IsNotNull(CommandRegistry.Handle(A.Fake<ICommandContext>(), ".test")); | ||
} | ||
|
||
[Test] | ||
public void Regular_Class_Static_Method_Command() | ||
{ | ||
CommandRegistry.RegisterCommandType(typeof(RegularClassTestCommands)); | ||
Assert.IsNotNull(CommandRegistry.Handle(A.Fake<ICommandContext>(), ".test")); | ||
} | ||
|
||
public static class StaticClassTestCommands | ||
{ | ||
[ChatCommand("test")] | ||
public static void Test(ICommandContext ctx) { } | ||
} | ||
|
||
public class RegularClassTestCommands | ||
{ | ||
public RegularClassTestCommands(ICommandContext ctx) | ||
{ | ||
Assert.Fail("Should not run this."); | ||
} | ||
|
||
[ChatCommand("test")] | ||
public static void Test(ICommandContext ctx) { } | ||
} | ||
} |