-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Showing
4 changed files
with
74 additions
and
13 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
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
61 changes: 61 additions & 0 deletions
61
tests/Maui/Prism.DryIoc.Maui.Tests/Fixtures/Modularity/ModuleCatalogTests.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,61 @@ | ||
namespace Prism.DryIoc.Maui.Tests.Fixtures.Modularity; | ||
|
||
public class ModuleCatalogTests(ITestOutputHelper testOutputHelper) : TestBase(testOutputHelper) | ||
{ | ||
public readonly IModuleInfo ModuleA = new ModuleInfo(typeof(MockModuleA)); | ||
|
||
[Fact] | ||
public void UsesCustomModuleCatalog() | ||
{ | ||
var builder = CreateBuilder(prism => | ||
{ | ||
prism.RegisterTypes(c => c.RegisterSingleton<IModuleCatalog, CustomMoudleCatalog>()) | ||
.ConfigureModuleCatalog(catalog => { }); | ||
}); | ||
var app = builder.Build(); | ||
|
||
var moduleCatalog = app.Services.GetService<IModuleCatalog>(); | ||
Assert.NotNull(moduleCatalog); | ||
Assert.IsType<CustomMoudleCatalog>(moduleCatalog); | ||
} | ||
|
||
[Fact] | ||
public void InjectsModulesFromDI() | ||
{ | ||
var builder = CreateBuilder(prism => | ||
{ | ||
prism.RegisterTypes(c => c.RegisterInstance<IModuleInfo>(ModuleA)) | ||
.ConfigureModuleCatalog(c => { }); | ||
}); | ||
var app = builder.Build(); | ||
|
||
var moduleCatalog = app.Services.GetService<IModuleCatalog>(); | ||
Assert.Single(moduleCatalog.Modules); | ||
Assert.Equal(ModuleA.ModuleType, moduleCatalog.Modules.Single().ModuleType); | ||
} | ||
|
||
[Fact] | ||
public void InjectsModulesFromConfigureDelegate() | ||
{ | ||
var builder = CreateBuilder(prism => | ||
prism.ConfigureModuleCatalog(c => c.AddModule<MockModuleA>())); | ||
var app = builder.Build(); | ||
|
||
var moduleCatalog = app.Services.GetService<IModuleCatalog>(); | ||
Assert.Single(moduleCatalog.Modules); | ||
Assert.Equal(ModuleA.ModuleType, moduleCatalog.Modules.Single().ModuleType); | ||
} | ||
|
||
public class CustomMoudleCatalog : ModuleCatalogBase { } | ||
|
||
public class MockModuleA : IModule | ||
{ | ||
public void OnInitialized(IContainerProvider containerProvider) | ||
{ | ||
} | ||
|
||
public void RegisterTypes(IContainerRegistry containerRegistry) | ||
{ | ||
} | ||
} | ||
} |