From 27e1d4accbea0a41a0206d126c532dd3952adb06 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Fri, 27 Nov 2015 00:25:06 +0300 Subject: [PATCH] Fix for FullLayoutTests --- .../Primitives/WindowingPlatformMock.cs | 15 ++++++++++++--- tests/Perspex.Layout.UnitTests/FullLayoutTests.cs | 3 ++- .../Perspex.Layout.UnitTests.csproj | 4 ++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/Perspex.Controls.UnitTests/Primitives/WindowingPlatformMock.cs b/tests/Perspex.Controls.UnitTests/Primitives/WindowingPlatformMock.cs index bb879929a5..6dde6ef4d1 100644 --- a/tests/Perspex.Controls.UnitTests/Primitives/WindowingPlatformMock.cs +++ b/tests/Perspex.Controls.UnitTests/Primitives/WindowingPlatformMock.cs @@ -4,11 +4,20 @@ using Perspex.Platform; namespace Perspex.Controls.UnitTests.Primitives { - class WindowingPlatformMock : IWindowingPlatform + public class WindowingPlatformMock : IWindowingPlatform { + private readonly Func _windowImpl; + private readonly Func _popupImpl; + + public WindowingPlatformMock(Func windowImpl = null, Func popupImpl = null ) + { + _windowImpl = windowImpl; + _popupImpl = popupImpl; + } + public IWindowImpl CreateWindow() { - return new Mock().Object; + return _windowImpl?.Invoke() ?? new Mock().Object; } public IWindowImpl CreateDesignerFriendlyWindow() @@ -16,6 +25,6 @@ namespace Perspex.Controls.UnitTests.Primitives throw new NotImplementedException(); } - public IPopupImpl CreatePopup() => new Mock().Object; + public IPopupImpl CreatePopup() => _popupImpl?.Invoke() ?? new Mock().Object; } } \ No newline at end of file diff --git a/tests/Perspex.Layout.UnitTests/FullLayoutTests.cs b/tests/Perspex.Layout.UnitTests/FullLayoutTests.cs index 53a74dec19..88c0e53827 100644 --- a/tests/Perspex.Layout.UnitTests/FullLayoutTests.cs +++ b/tests/Perspex.Layout.UnitTests/FullLayoutTests.cs @@ -9,6 +9,7 @@ using Perspex.Controls; using Perspex.Controls.Presenters; using Perspex.Controls.Primitives; using Perspex.Controls.Templates; +using Perspex.Controls.UnitTests.Primitives; using Perspex.Diagnostics; using Perspex.Input; using Perspex.Platform; @@ -149,7 +150,7 @@ namespace Perspex.Layout.UnitTests .Bind().ToConstant(renderInterface) .Bind().ToConstant(renderManager) .Bind().ToConstant(new Styler()) - .Bind().ToConstant(windowImpl.Object); + .Bind().ToConstant(new WindowingPlatformMock(() => windowImpl.Object)); var theme = new DefaultTheme(); globalStyles.Setup(x => x.Styles).Returns(theme); diff --git a/tests/Perspex.Layout.UnitTests/Perspex.Layout.UnitTests.csproj b/tests/Perspex.Layout.UnitTests/Perspex.Layout.UnitTests.csproj index 15f1a5cc25..08e0e2c7a0 100644 --- a/tests/Perspex.Layout.UnitTests/Perspex.Layout.UnitTests.csproj +++ b/tests/Perspex.Layout.UnitTests/Perspex.Layout.UnitTests.csproj @@ -137,6 +137,10 @@ {3E10A5FA-E8DA-48B1-AD44-6A5B6CB7750F} Perspex.Themes.Default + + {5ccb5571-7c30-4e7d-967d-0e2158ebd91f} + Perspex.Controls.UnitTests +