|
|
|
@ -12,22 +12,17 @@ namespace Avalonia.UnitTests |
|
|
|
{ |
|
|
|
public class UnitTestApplication : Application |
|
|
|
{ |
|
|
|
private readonly TestServices _services; |
|
|
|
|
|
|
|
public UnitTestApplication(TestServices services) |
|
|
|
{ |
|
|
|
Services = services ?? new TestServices(); |
|
|
|
_services = services ?? new TestServices(); |
|
|
|
RegisterServices(); |
|
|
|
|
|
|
|
var styles = Services.Theme?.Invoke(); |
|
|
|
|
|
|
|
if (styles != null) |
|
|
|
{ |
|
|
|
Styles.AddRange(styles); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static new UnitTestApplication Current => (UnitTestApplication)Application.Current; |
|
|
|
|
|
|
|
public TestServices Services { get; } |
|
|
|
public TestServices Services => _services; |
|
|
|
|
|
|
|
public static IDisposable Start(TestServices services = null) |
|
|
|
{ |
|
|
|
@ -37,7 +32,7 @@ namespace Avalonia.UnitTests |
|
|
|
return scope; |
|
|
|
} |
|
|
|
|
|
|
|
protected override void RegisterServices() |
|
|
|
public override void RegisterServices() |
|
|
|
{ |
|
|
|
AvaloniaLocator.CurrentMutable |
|
|
|
.Bind<IAssetLoader>().ToConstant(Services.AssetLoader) |
|
|
|
@ -53,6 +48,12 @@ namespace Avalonia.UnitTests |
|
|
|
.Bind<IStyler>().ToConstant(Services.Styler) |
|
|
|
.Bind<IWindowingPlatform>().ToConstant(Services.WindowingPlatform) |
|
|
|
.Bind<IApplicationLifecycle>().ToConstant(this); |
|
|
|
var styles = Services.Theme?.Invoke(); |
|
|
|
|
|
|
|
if (styles != null) |
|
|
|
{ |
|
|
|
Styles.AddRange(styles); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|