// Copyright (c) The Perspex Project. All rights reserved. // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; using Perspex.Input; using Perspex.Layout; using Perspex.Platform; using Perspex.Styling; namespace Perspex.UnitTests { public class UnitTestApplication : Application { public UnitTestApplication(TestServices services) { Services = services ?? new TestServices(); RegisterServices(); Styles = Services.Theme?.Invoke(); } public static new UnitTestApplication Current => (UnitTestApplication)Application.Current; public TestServices Services { get; } public static IDisposable Start(TestServices services = null) { var scope = PerspexLocator.EnterScope(); var app = new UnitTestApplication(services); return scope; } protected override void RegisterServices() { PerspexLocator.CurrentMutable .Bind().ToConstant(Services.AssetLoader) .BindToSelf(this) .Bind().ToConstant(Services.InputManager) .Bind().ToConstant(Services.LayoutManager) .Bind().ToConstant(Services.PlatformWrapper) .Bind().ToConstant(Services.RenderInterface) .Bind().ToConstant(Services.ThreadingInterface) .Bind().ToConstant(Services.StandardCursorFactory) .Bind().ToConstant(Services.Styler) .Bind().ToConstant(Services.WindowingPlatform); } } }