|
|
@@ -1,4 +1,5 @@
|
|
|
-using Avalonia.Controls.UnitTests;
|
|
|
+using System;
|
|
|
+using Avalonia.Controls.UnitTests;
|
|
|
using Avalonia.Platform;
|
|
|
using Xunit;
|
|
|
|
|
|
@@ -18,6 +19,22 @@ namespace Avalonia.Controls.UnitTests
|
|
|
{
|
|
|
}
|
|
|
|
|
|
+ public class AppWithDependencies : Application
|
|
|
+ {
|
|
|
+ public AppWithDependencies()
|
|
|
+ {
|
|
|
+ throw new NotSupportedException();
|
|
|
+ }
|
|
|
+
|
|
|
+ public AppWithDependencies(object dependencyA, object dependencyB)
|
|
|
+ {
|
|
|
+ DependencyA = dependencyA;
|
|
|
+ DependencyB = dependencyB;
|
|
|
+ }
|
|
|
+ public object DependencyA { get; }
|
|
|
+ public object DependencyB { get; }
|
|
|
+ }
|
|
|
+
|
|
|
public class DefaultModule
|
|
|
{
|
|
|
public static bool IsLoaded = false;
|
|
|
@@ -53,7 +70,30 @@ namespace Avalonia.Controls.UnitTests
|
|
|
IsLoaded = true;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ [Fact]
|
|
|
+ public void UseAppFactory()
|
|
|
+ {
|
|
|
+ using (AvaloniaLocator.EnterScope())
|
|
|
+ {
|
|
|
+ ResetModuleLoadStates();
|
|
|
+
|
|
|
+ Func<AppWithDependencies> appFactory = () => new AppWithDependencies(dependencyA: new object(), dependencyB: new object());
|
|
|
+
|
|
|
+ var builder = AppBuilder.Configure<AppWithDependencies>(appFactory)
|
|
|
+ .UseWindowingSubsystem(() => { })
|
|
|
+ .UseRenderingSubsystem(() => { })
|
|
|
+ .UseAvaloniaModules()
|
|
|
+ .SetupWithoutStarting();
|
|
|
+
|
|
|
+ AppWithDependencies app = (AppWithDependencies)builder.Instance;
|
|
|
+ Assert.NotNull(app.DependencyA);
|
|
|
+ Assert.NotNull(app.DependencyB);
|
|
|
+
|
|
|
+ Assert.True(DefaultModule.IsLoaded);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
[Fact]
|
|
|
public void LoadsDefaultModule()
|
|
|
{
|