101 changed files with 1152 additions and 994 deletions
@ -1,38 +0,0 @@ |
|||
// 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 Moq; |
|||
using Perspex.Layout; |
|||
using Perspex.Platform; |
|||
using Perspex.Rendering; |
|||
using Perspex.Styling; |
|||
|
|||
namespace Perspex.Controls.UnitTests |
|||
{ |
|||
internal class TestRoot : Decorator, ILayoutRoot, IRenderRoot, IStyleRoot |
|||
{ |
|||
public Size ClientSize => new Size(100, 100); |
|||
|
|||
public Size MaxClientSize => Size.Infinity; |
|||
|
|||
public ILayoutManager LayoutManager => new Mock<ILayoutManager>().Object; |
|||
|
|||
public IRenderTarget RenderTarget |
|||
{ |
|||
get { throw new NotImplementedException(); } |
|||
} |
|||
|
|||
public IRenderQueueManager RenderQueueManager => null; |
|||
|
|||
public Point PointToClient(Point p) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public Point PointToScreen(Point p) |
|||
{ |
|||
return new Point(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,47 +0,0 @@ |
|||
// 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 Moq; |
|||
using Perspex.Controls.UnitTests; |
|||
using Perspex.Layout; |
|||
using Perspex.Platform; |
|||
using Perspex.Shared.PlatformSupport; |
|||
using Perspex.Themes.Default; |
|||
using Ploeh.AutoFixture; |
|||
using Ploeh.AutoFixture.AutoMoq; |
|||
|
|||
namespace Perspex.LeakTests |
|||
{ |
|||
internal class TestApp : Application |
|||
{ |
|||
private TestApp() |
|||
{ |
|||
RegisterServices(); |
|||
|
|||
var fixture = new Fixture().Customize(new AutoMoqCustomization()); |
|||
var windowImpl = new Mock<IWindowImpl>(); |
|||
var renderInterface = fixture.Create<IPlatformRenderInterface>(); |
|||
var threadingInterface = Mock.Of<IPlatformThreadingInterface>(x => |
|||
x.CurrentThreadIsLoopThread == true); |
|||
|
|||
PerspexLocator.CurrentMutable |
|||
.Bind<IAssetLoader>().ToConstant(new AssetLoader()) |
|||
.Bind<ILayoutManager>().ToConstant(new LayoutManager()) |
|||
.Bind<IPclPlatformWrapper>().ToConstant(new PclPlatformWrapper()) |
|||
.Bind<IPlatformRenderInterface>().ToConstant(renderInterface) |
|||
.Bind<IPlatformThreadingInterface>().ToConstant(threadingInterface) |
|||
.Bind<IStandardCursorFactory>().ToConstant(new Mock<IStandardCursorFactory>().Object) |
|||
.Bind<IWindowingPlatform>().ToConstant(new WindowingPlatformMock(() => windowImpl.Object)); |
|||
|
|||
Styles = new DefaultTheme(); |
|||
} |
|||
|
|||
public static void Initialize() |
|||
{ |
|||
if (Current == null) |
|||
{ |
|||
new TestApp(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -1,67 +0,0 @@ |
|||
// 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.Controls; |
|||
using Perspex.Platform; |
|||
using Perspex.Rendering; |
|||
using Perspex.Styling; |
|||
|
|||
namespace Perspex.Markup.Xaml.UnitTests |
|||
{ |
|||
public class TestRoot : Decorator, IRenderRoot, INameScope, IStyleRoot |
|||
{ |
|||
private readonly NameScope _nameScope = new NameScope(); |
|||
|
|||
event EventHandler<NameScopeEventArgs> INameScope.Registered |
|||
{ |
|||
add { _nameScope.Registered += value; ++NameScopeRegisteredSubscribers; } |
|||
remove { _nameScope.Registered -= value; --NameScopeRegisteredSubscribers; } |
|||
} |
|||
|
|||
public event EventHandler<NameScopeEventArgs> Unregistered |
|||
{ |
|||
add { _nameScope.Unregistered += value; ++NameScopeUnregisteredSubscribers; } |
|||
remove { _nameScope.Unregistered -= value; --NameScopeUnregisteredSubscribers; } |
|||
} |
|||
|
|||
public int NameScopeRegisteredSubscribers { get; private set; } |
|||
|
|||
public int NameScopeUnregisteredSubscribers { get; private set; } |
|||
|
|||
public IRenderTarget RenderTarget |
|||
{ |
|||
get { throw new NotImplementedException(); } |
|||
} |
|||
|
|||
public IRenderQueueManager RenderQueueManager |
|||
{ |
|||
get { throw new NotImplementedException(); } |
|||
} |
|||
|
|||
public Point PointToClient(Point p) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public Point PointToScreen(Point p) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public void Register(string name, object element) |
|||
{ |
|||
_nameScope.Register(name, element); |
|||
} |
|||
|
|||
public object Find(string name) |
|||
{ |
|||
return _nameScope.Find(name); |
|||
} |
|||
|
|||
public void Unregister(string name) |
|||
{ |
|||
_nameScope.Unregister(name); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<configuration> |
|||
<runtime> |
|||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|||
<dependentAssembly> |
|||
<assemblyIdentity name="Moq" publicKeyToken="69f491c39445e920" culture="neutral" /> |
|||
<bindingRedirect oldVersion="0.0.0.0-4.2.1510.2205" newVersion="4.2.1510.2205" /> |
|||
</dependentAssembly> |
|||
</assemblyBinding> |
|||
</runtime> |
|||
</configuration> |
|||
@ -1,39 +0,0 @@ |
|||
// 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 Moq; |
|||
using Perspex.Controls; |
|||
using Perspex.Layout; |
|||
using Perspex.Platform; |
|||
using Perspex.Rendering; |
|||
|
|||
namespace Perspex.Styling.UnitTests |
|||
{ |
|||
internal class TestRoot : Decorator, ILayoutRoot, IRenderRoot, IStyleRoot |
|||
{ |
|||
public Size ClientSize => new Size(100, 100); |
|||
|
|||
public Size MaxClientSize => Size.Infinity; |
|||
|
|||
public IRenderTarget RenderTarget |
|||
{ |
|||
get { throw new NotImplementedException(); } |
|||
} |
|||
|
|||
public IRenderQueueManager RenderQueueManager |
|||
{ |
|||
get { throw new NotImplementedException(); } |
|||
} |
|||
|
|||
public Point PointToClient(Point p) |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public Point PointToScreen(Point p) |
|||
{ |
|||
return new Point(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
using System; |
|||
using Moq; |
|||
using Perspex.Platform; |
|||
|
|||
namespace Perspex.UnitTests |
|||
{ |
|||
public class MockWindowingPlatform : IWindowingPlatform |
|||
{ |
|||
private readonly Func<IWindowImpl> _windowImpl; |
|||
private readonly Func<IPopupImpl> _popupImpl; |
|||
|
|||
public MockWindowingPlatform(Func<IWindowImpl> windowImpl = null, Func<IPopupImpl> popupImpl = null ) |
|||
{ |
|||
_windowImpl = windowImpl; |
|||
_popupImpl = popupImpl; |
|||
} |
|||
|
|||
public IWindowImpl CreateWindow() |
|||
{ |
|||
return _windowImpl?.Invoke() ?? Mock.Of<IWindowImpl>(); |
|||
} |
|||
|
|||
public IWindowImpl CreateEmbeddableWindow() |
|||
{ |
|||
throw new NotImplementedException(); |
|||
} |
|||
|
|||
public IPopupImpl CreatePopup() => _popupImpl?.Invoke() ?? Mock.Of<IPopupImpl>(); |
|||
} |
|||
} |
|||
@ -0,0 +1,143 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProjectGuid>{88060192-33D5-4932-B0F9-8BD2763E857D}</ProjectGuid> |
|||
<ProjectGuid>{88060192-33D5-4932-B0F9-8BD2763E857D}</ProjectGuid> |
|||
<OutputType>Library</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>Perspex.UnitTests</RootNamespace> |
|||
<AssemblyName>Perspex.UnitTests</AssemblyName> |
|||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> |
|||
<FileAlignment>512</FileAlignment> |
|||
<TargetFrameworkProfile /> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Reference Include="Moq, Version=4.2.1510.2205, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="Ploeh.AutoFixture, Version=3.40.0.0, Culture=neutral, PublicKeyToken=b24654c590009d4f, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\AutoFixture.3.40.0\lib\net40\Ploeh.AutoFixture.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="Ploeh.AutoFixture.AutoMoq, Version=3.40.0.0, Culture=neutral, PublicKeyToken=b24654c590009d4f, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\AutoFixture.AutoMoq.3.40.0\lib\net40\Ploeh.AutoFixture.AutoMoq.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.Core" /> |
|||
<Reference Include="System.Reactive.Core, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\Rx-Core.2.2.5\lib\net45\System.Reactive.Core.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="System.Reactive.Interfaces, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\Rx-Interfaces.2.2.5\lib\net45\System.Reactive.Interfaces.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="System.Reactive.Linq, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\Rx-Linq.2.2.5\lib\net45\System.Reactive.Linq.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="System.Reactive.PlatformServices, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\Rx-PlatformServices.2.2.5\lib\net45\System.Reactive.PlatformServices.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="System.Xml.Linq" /> |
|||
<Reference Include="System.Data.DataSetExtensions" /> |
|||
<Reference Include="Microsoft.CSharp" /> |
|||
<Reference Include="System.Data" /> |
|||
<Reference Include="System.Net.Http" /> |
|||
<Reference Include="System.Xml" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Include="TestTemplatedRoot.cs" /> |
|||
<Compile Include="TestRoot.cs" /> |
|||
<Compile Include="TestServices.cs" /> |
|||
<Compile Include="UnitTestApplication.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
<Compile Include="MockWindowingPlatform.cs" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\src\Markup\Perspex.Markup.Xaml\Perspex.Markup.Xaml.csproj"> |
|||
<Project>{3e53a01a-b331-47f3-b828-4a5717e77a24}</Project> |
|||
<Name>Perspex.Markup.Xaml</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Markup\Perspex.Markup\Perspex.Markup.csproj"> |
|||
<Project>{6417e941-21bc-467b-a771-0de389353ce6}</Project> |
|||
<Name>Perspex.Markup</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Perspex.Animation\Perspex.Animation.csproj"> |
|||
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project> |
|||
<Name>Perspex.Animation</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Perspex.Application\Perspex.Application.csproj"> |
|||
<Project>{799a7bb5-3c2c-48b6-85a7-406a12c420da}</Project> |
|||
<Name>Perspex.Application</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Perspex.Base\Perspex.Base.csproj"> |
|||
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project> |
|||
<Name>Perspex.Base</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Perspex.Controls\Perspex.Controls.csproj"> |
|||
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project> |
|||
<Name>Perspex.Controls</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Perspex.Input\Perspex.Input.csproj"> |
|||
<Project>{62024b2d-53eb-4638-b26b-85eeaa54866e}</Project> |
|||
<Name>Perspex.Input</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Perspex.Interactivity\Perspex.Interactivity.csproj"> |
|||
<Project>{6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}</Project> |
|||
<Name>Perspex.Interactivity</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Perspex.Layout\Perspex.Layout.csproj"> |
|||
<Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project> |
|||
<Name>Perspex.Layout</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Perspex.SceneGraph\Perspex.SceneGraph.csproj"> |
|||
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project> |
|||
<Name>Perspex.SceneGraph</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Perspex.Styling\Perspex.Styling.csproj"> |
|||
<Project>{f1baa01a-f176-4c6a-b39d-5b40bb1b148f}</Project> |
|||
<Name>Perspex.Styling</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\src\Perspex.Themes.Default\Perspex.Themes.Default.csproj"> |
|||
<Project>{3e10a5fa-e8da-48b1-ad44-6a5b6cb7750f}</Project> |
|||
<Name>Perspex.Themes.Default</Name> |
|||
</ProjectReference> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="app.config" /> |
|||
<None Include="packages.config" /> |
|||
</ItemGroup> |
|||
<Import Project="..\..\src\Shared\PlatformSupport\PlatformSupport.projitems" Label="Shared" /> |
|||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
|||
Other similar extension points exist, see Microsoft.Common.targets. |
|||
<Target Name="BeforeBuild"> |
|||
</Target> |
|||
<Target Name="AfterBuild"> |
|||
</Target> |
|||
--> |
|||
</Project> |
|||
@ -0,0 +1,36 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
[assembly: AssemblyTitle("Perspex.UnitTests")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("Perspex.UnitTests")] |
|||
[assembly: AssemblyCopyright("Copyright © 2016")] |
|||
[assembly: AssemblyTrademark("")] |
|||
[assembly: AssemblyCulture("")] |
|||
|
|||
// Setting ComVisible to false makes the types in this assembly not visible
|
|||
// to COM components. If you need to access a type in this assembly from
|
|||
// COM, set the ComVisible attribute to true on that type.
|
|||
[assembly: ComVisible(false)] |
|||
|
|||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|||
[assembly: Guid("88060192-33d5-4932-b0f9-8bd2763e857d")] |
|||
|
|||
// Version information for an assembly consists of the following four values:
|
|||
//
|
|||
// Major Version
|
|||
// Minor Version
|
|||
// Build Number
|
|||
// Revision
|
|||
//
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
|||
// by using the '*' as shown below:
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
|||
[assembly: AssemblyVersion("1.0.0.0")] |
|||
[assembly: AssemblyFileVersion("1.0.0.0")] |
|||
@ -0,0 +1,110 @@ |
|||
// 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 System.Reflection; |
|||
using Moq; |
|||
using Perspex.Input; |
|||
using Perspex.Layout; |
|||
using Perspex.Platform; |
|||
using Perspex.Shared.PlatformSupport; |
|||
using Perspex.Styling; |
|||
using Perspex.Themes.Default; |
|||
using Ploeh.AutoFixture; |
|||
using Ploeh.AutoFixture.AutoMoq; |
|||
|
|||
namespace Perspex.UnitTests |
|||
{ |
|||
public class TestServices |
|||
{ |
|||
private static IFixture s_fixture = new Fixture().Customize(new AutoMoqCustomization()); |
|||
|
|||
public static readonly TestServices StyledWindow = new TestServices( |
|||
assetLoader: new AssetLoader(), |
|||
layoutManager: new LayoutManager(), |
|||
platformWrapper: new PclPlatformWrapper(), |
|||
renderInterface: s_fixture.Create<IPlatformRenderInterface>(), |
|||
standardCursorFactory: Mock.Of<IStandardCursorFactory>(), |
|||
styler: new Styler(), |
|||
theme: () => new DefaultTheme(), |
|||
threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true), |
|||
windowingPlatform: new MockWindowingPlatform()); |
|||
|
|||
public static readonly TestServices MockPlatformWrapper = new TestServices( |
|||
platformWrapper: Mock.Of<IPclPlatformWrapper>()); |
|||
|
|||
public static readonly TestServices MockStyler = new TestServices( |
|||
styler: Mock.Of<IStyler>()); |
|||
|
|||
public static readonly TestServices MockThreadingInterface = new TestServices( |
|||
threadingInterface: Mock.Of<IPlatformThreadingInterface>(x => x.CurrentThreadIsLoopThread == true)); |
|||
|
|||
public static readonly TestServices RealStyler = new TestServices( |
|||
styler: new Styler()); |
|||
|
|||
public TestServices( |
|||
IAssetLoader assetLoader = null, |
|||
IInputManager inputManager = null, |
|||
ILayoutManager layoutManager = null, |
|||
IPclPlatformWrapper platformWrapper = null, |
|||
IPlatformRenderInterface renderInterface = null, |
|||
IStandardCursorFactory standardCursorFactory = null, |
|||
IStyler styler = null, |
|||
Func<Styles> theme = null, |
|||
IPlatformThreadingInterface threadingInterface = null, |
|||
IWindowImpl windowImpl = null, |
|||
IWindowingPlatform windowingPlatform = null) |
|||
{ |
|||
AssetLoader = assetLoader; |
|||
InputManager = inputManager; |
|||
LayoutManager = layoutManager; |
|||
PlatformWrapper = platformWrapper; |
|||
RenderInterface = renderInterface; |
|||
StandardCursorFactory = standardCursorFactory; |
|||
Styler = styler; |
|||
Theme = theme; |
|||
ThreadingInterface = threadingInterface; |
|||
WindowImpl = windowImpl; |
|||
WindowingPlatform = windowingPlatform; |
|||
} |
|||
|
|||
public IAssetLoader AssetLoader { get; } |
|||
public IInputManager InputManager { get; } |
|||
public ILayoutManager LayoutManager { get; } |
|||
public IPclPlatformWrapper PlatformWrapper { get; } |
|||
public IPlatformRenderInterface RenderInterface { get; } |
|||
public IStandardCursorFactory StandardCursorFactory { get; } |
|||
public IStyler Styler { get; } |
|||
public Func<Styles> Theme { get; } |
|||
public IPlatformThreadingInterface ThreadingInterface { get; } |
|||
public IWindowImpl WindowImpl { get; } |
|||
public IWindowingPlatform WindowingPlatform { get; } |
|||
|
|||
public TestServices With( |
|||
IAssetLoader assetLoader = null, |
|||
IInputManager inputManager = null, |
|||
ILayoutManager layoutManager = null, |
|||
IPclPlatformWrapper platformWrapper = null, |
|||
IPlatformRenderInterface renderInterface = null, |
|||
IStandardCursorFactory standardCursorFactory = null, |
|||
IStyler styler = null, |
|||
Func<Styles> theme = null, |
|||
IPlatformThreadingInterface threadingInterface = null, |
|||
IWindowImpl windowImpl = null, |
|||
IWindowingPlatform windowingPlatform = null) |
|||
{ |
|||
return new TestServices( |
|||
assetLoader: assetLoader ?? AssetLoader, |
|||
inputManager: inputManager ?? InputManager, |
|||
layoutManager: layoutManager ?? LayoutManager, |
|||
platformWrapper: platformWrapper ?? PlatformWrapper, |
|||
renderInterface: renderInterface ?? RenderInterface, |
|||
standardCursorFactory: standardCursorFactory ?? StandardCursorFactory, |
|||
styler: styler ?? Styler, |
|||
theme: theme ?? Theme, |
|||
threadingInterface: threadingInterface ?? ThreadingInterface, |
|||
windowImpl: windowImpl ?? WindowImpl, |
|||
windowingPlatform: windowingPlatform ?? WindowingPlatform); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,65 @@ |
|||
// 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.Controls; |
|||
using Perspex.Controls.Presenters; |
|||
using Perspex.Controls.Templates; |
|||
using Perspex.Layout; |
|||
using Perspex.Platform; |
|||
using Perspex.Rendering; |
|||
using Perspex.Styling; |
|||
|
|||
namespace Perspex.UnitTests |
|||
{ |
|||
public class TestTemplatedRoot : ContentControl, ILayoutRoot, INameScope, IRenderRoot, IStyleRoot |
|||
{ |
|||
private readonly NameScope _nameScope = new NameScope(); |
|||
|
|||
public TestTemplatedRoot() |
|||
{ |
|||
Template = new FuncControlTemplate<TestTemplatedRoot>(x => new ContentPresenter()); |
|||
} |
|||
|
|||
public event EventHandler<NameScopeEventArgs> Registered |
|||
{ |
|||
add { _nameScope.Registered += value; } |
|||
remove { _nameScope.Registered -= value; } |
|||
} |
|||
|
|||
public event EventHandler<NameScopeEventArgs> Unregistered |
|||
{ |
|||
add { _nameScope.Unregistered += value; } |
|||
remove { _nameScope.Unregistered -= value; } |
|||
} |
|||
|
|||
public Size ClientSize => new Size(100, 100); |
|||
|
|||
public Size MaxClientSize => Size.Infinity; |
|||
|
|||
public ILayoutManager LayoutManager => PerspexLocator.Current.GetService<ILayoutManager>(); |
|||
|
|||
public IRenderTarget RenderTarget => null; |
|||
|
|||
public IRenderQueueManager RenderQueueManager => null; |
|||
|
|||
public Point PointToClient(Point p) => p; |
|||
|
|||
public Point PointToScreen(Point p) => p; |
|||
|
|||
void INameScope.Register(string name, object element) |
|||
{ |
|||
_nameScope.Register(name, element); |
|||
} |
|||
|
|||
object INameScope.Find(string name) |
|||
{ |
|||
return _nameScope.Find(name); |
|||
} |
|||
|
|||
void INameScope.Unregister(string name) |
|||
{ |
|||
_nameScope.Unregister(name); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,47 @@ |
|||
// 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<IAssetLoader>().ToConstant(Services.AssetLoader) |
|||
.BindToSelf<IGlobalStyles>(this) |
|||
.Bind<IInputManager>().ToConstant(Services.InputManager) |
|||
.Bind<ILayoutManager>().ToConstant(Services.LayoutManager) |
|||
.Bind<IPclPlatformWrapper>().ToConstant(Services.PlatformWrapper) |
|||
.Bind<IPlatformRenderInterface>().ToConstant(Services.RenderInterface) |
|||
.Bind<IPlatformThreadingInterface>().ToConstant(Services.ThreadingInterface) |
|||
.Bind<IStandardCursorFactory>().ToConstant(Services.StandardCursorFactory) |
|||
.Bind<IStyler>().ToConstant(Services.Styler) |
|||
.Bind<IWindowingPlatform>().ToConstant(Services.WindowingPlatform); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<configuration> |
|||
<runtime> |
|||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|||
<dependentAssembly> |
|||
<assemblyIdentity name="Moq" publicKeyToken="69f491c39445e920" culture="neutral" /> |
|||
<bindingRedirect oldVersion="0.0.0.0-4.2.1510.2205" newVersion="4.2.1510.2205" /> |
|||
</dependentAssembly> |
|||
</assemblyBinding> |
|||
</runtime> |
|||
</configuration> |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue