generated from vrchat-community/template-package
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support multiple ExportsPlugin declarations
- Loading branch information
1 parent
08b8419
commit 73c8f9b
Showing
4 changed files
with
55 additions
and
1 deletion.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
UnitTests~/PluginResolverTests/SupportsMultipleDeclarations.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,43 @@ | ||
using System.Collections.Immutable; | ||
using System.Linq; | ||
using nadena.dev.ndmf; | ||
using NUnit.Framework; | ||
using UnitTests.ExportsPluginTest; | ||
|
||
[assembly: ExportsPlugin(typeof(PluginA))] | ||
[assembly: ExportsPlugin(typeof(PluginB))] | ||
|
||
namespace UnitTests.ExportsPluginTest | ||
{ | ||
internal class PluginA : Plugin<PluginA> | ||
{ | ||
protected override void Configure() | ||
{ | ||
InPhase(BuildPhase.Transforming).Run("test", _ctx => { }); | ||
} | ||
} | ||
|
||
internal class PluginB : Plugin<PluginB> | ||
{ | ||
protected override void Configure() | ||
{ | ||
InPhase(BuildPhase.Transforming).Run("test", _ctx => { }); | ||
} | ||
} | ||
|
||
public class SupportsMultipleDeclarations | ||
{ | ||
[Test] | ||
public void TestSupportsMultipleDeclarations() | ||
{ | ||
var resolver = new PluginResolver(); | ||
var plugins = | ||
resolver.Passes.SelectMany(kv => kv.Item2) // passes per phase | ||
.Select(pass => pass.Plugin.GetType()) | ||
.ToImmutableHashSet(); | ||
|
||
Assert.IsTrue(plugins.Contains(typeof(PluginA))); | ||
Assert.IsTrue(plugins.Contains(typeof(PluginB))); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
UnitTests~/PluginResolverTests/SupportsMultipleDeclarations.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.