Browse Source

Fix for FullLayoutTests

pull/332/head
Nikita Tsukanov 11 years ago
parent
commit
27e1d4accb
  1. 15
      tests/Perspex.Controls.UnitTests/Primitives/WindowingPlatformMock.cs
  2. 3
      tests/Perspex.Layout.UnitTests/FullLayoutTests.cs
  3. 4
      tests/Perspex.Layout.UnitTests/Perspex.Layout.UnitTests.csproj

15
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<IWindowImpl> _windowImpl;
private readonly Func<IPopupImpl> _popupImpl;
public WindowingPlatformMock(Func<IWindowImpl> windowImpl = null, Func<IPopupImpl> popupImpl = null )
{
_windowImpl = windowImpl;
_popupImpl = popupImpl;
}
public IWindowImpl CreateWindow()
{
return new Mock<IWindowImpl>().Object;
return _windowImpl?.Invoke() ?? new Mock<IWindowImpl>().Object;
}
public IWindowImpl CreateDesignerFriendlyWindow()
@ -16,6 +25,6 @@ namespace Perspex.Controls.UnitTests.Primitives
throw new NotImplementedException();
}
public IPopupImpl CreatePopup() => new Mock<IPopupImpl>().Object;
public IPopupImpl CreatePopup() => _popupImpl?.Invoke() ?? new Mock<IPopupImpl>().Object;
}
}

3
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<IPlatformRenderInterface>().ToConstant(renderInterface)
.Bind<IRenderQueueManager>().ToConstant(renderManager)
.Bind<IStyler>().ToConstant(new Styler())
.Bind<IWindowImpl>().ToConstant(windowImpl.Object);
.Bind<IWindowingPlatform>().ToConstant(new WindowingPlatformMock(() => windowImpl.Object));
var theme = new DefaultTheme();
globalStyles.Setup(x => x.Styles).Returns(theme);

4
tests/Perspex.Layout.UnitTests/Perspex.Layout.UnitTests.csproj

@ -137,6 +137,10 @@
<Project>{3E10A5FA-E8DA-48B1-AD44-6A5B6CB7750F}</Project>
<Name>Perspex.Themes.Default</Name>
</ProjectReference>
<ProjectReference Include="..\Perspex.Controls.UnitTests\Perspex.Controls.UnitTests.csproj">
<Project>{5ccb5571-7c30-4e7d-967d-0e2158ebd91f}</Project>
<Name>Perspex.Controls.UnitTests</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />

Loading…
Cancel
Save