Skip to content

Commit

Permalink
tests: add combination test
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Aug 5, 2024
1 parent c7bf3f8 commit ec5e8a6
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ namespace Prism.DryIoc.Maui.Tests.Fixtures.Modularity;
public class ModuleCatalogTests(ITestOutputHelper testOutputHelper) : TestBase(testOutputHelper)
{
public readonly IModuleInfo ModuleA = new ModuleInfo(typeof(MockModuleA));
public readonly IModuleInfo ModuleB = new ModuleInfo(typeof(MockModuleB));

[Fact]
public void UsesCustomModuleCatalog()
Expand Down Expand Up @@ -46,6 +47,22 @@ public void InjectsModulesFromConfigureDelegate()
Assert.Equal(ModuleA.ModuleType, moduleCatalog.Modules.Single().ModuleType);
}

[Fact]
public void CombinesModulesFromConfigureMethodAndDI()
{
var builder = CreateBuilder(prism =>
{
prism.RegisterTypes(c => c.RegisterInstance<IModuleInfo>(ModuleA))
.ConfigureModuleCatalog(c => c.AddModule<MockModuleB>());
});
var app = builder.Build();

var moduleCatalog = app.Services.GetService<IModuleCatalog>();
Assert.Equal(2, moduleCatalog.Modules.Count());
Assert.Contains(ModuleA.ModuleType, moduleCatalog.Modules.Select(m => m.ModuleType));
Assert.Contains(ModuleB.ModuleType, moduleCatalog.Modules.Select(m => m.ModuleType));
}

public class CustomMoudleCatalog : ModuleCatalogBase { }

public class MockModuleA : IModule
Expand All @@ -58,4 +75,15 @@ public void RegisterTypes(IContainerRegistry containerRegistry)
{
}
}

public class MockModuleB : IModule
{
public void OnInitialized(IContainerProvider containerProvider)
{
}

public void RegisterTypes(IContainerRegistry containerRegistry)
{
}
}
}

0 comments on commit ec5e8a6

Please sign in to comment.