UnitTestApplication.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright (c) The Perspex Project. All rights reserved.
  2. // Licensed under the MIT license. See licence.md file in the project root for full license information.
  3. using System;
  4. using Perspex.Layout;
  5. using Perspex.Platform;
  6. using Perspex.Styling;
  7. namespace Perspex.UnitTests
  8. {
  9. public class UnitTestApplication : Application
  10. {
  11. public UnitTestApplication(TestServices services)
  12. {
  13. Services = services;
  14. RegisterServices();
  15. Styles = services.Theme();
  16. }
  17. public TestServices Services { get; }
  18. public static IDisposable Start(TestServices services = null)
  19. {
  20. var scope = PerspexLocator.EnterScope();
  21. var app = new UnitTestApplication(services);
  22. return scope;
  23. }
  24. protected override void RegisterServices()
  25. {
  26. PerspexLocator.CurrentMutable
  27. .Bind<IAssetLoader>().ToConstant(Services.AssetLoader)
  28. .BindToSelf<IGlobalStyles>(this)
  29. .Bind<ILayoutManager>().ToConstant(Services.LayoutManager)
  30. .Bind<IPclPlatformWrapper>().ToConstant(Services.PlatformWrapper)
  31. .Bind<IPlatformRenderInterface>().ToConstant(Services.RenderInterface)
  32. .Bind<IPlatformThreadingInterface>().ToConstant(Services.ThreadingInterface)
  33. .Bind<IStandardCursorFactory>().ToConstant(Services.StandardCursorFactory)
  34. .Bind<IStyler>().ToConstant(Services.Styler)
  35. .Bind<IWindowingPlatform>().ToConstant(Services.WindowingPlatform);
  36. }
  37. }
  38. }