Skip to content

Commit

Permalink
Make our unit tests support library (Avalonia.UnitTests) target netst…
Browse files Browse the repository at this point in the history
…andard2.0 so we don't have to worry about targetting .NET Framework on linux.
  • Loading branch information
jkoritzinsky committed Jun 7, 2018
1 parent f985fc8 commit 4ec647b
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 45 deletions.
1 change: 0 additions & 1 deletion Avalonia.sln
Expand Up @@ -1813,7 +1813,6 @@ Global
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|NetCoreOnly.ActiveCfg = Debug|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|NetCoreOnly.Build.0 = Debug|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|x86.ActiveCfg = Debug|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Debug|x86.Build.0 = Debug|Any CPU
{4A1ABB09-9047-4BD5-A4AD-A055E52C5EE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down
11 changes: 1 addition & 10 deletions src/Avalonia.Controls/AppBuilderBase.cs
Expand Up @@ -209,16 +209,7 @@ public TAppBuilder UseRenderingSubsystem(Action initializer, string name = "")

public TAppBuilder UseAvaloniaModules() => AfterSetup(builder => SetupAvaloniaModules());

private bool CheckSetup { get; set; } = true;

/// <summary>
/// Set this AppBuilder to ignore the setup check. Used for testing purposes.
/// </summary>
internal TAppBuilder IgnoreSetupCheck()
{
CheckSetup = false;
return Self;
}
protected virtual bool CheckSetup => true;

private void SetupAvaloniaModules()
{
Expand Down
5 changes: 1 addition & 4 deletions tests/Avalonia.Controls.UnitTests/AppBuilderTests.cs
Expand Up @@ -6,6 +6,7 @@
using Xunit;
using Avalonia.Controls.UnitTests;
using Avalonia.Platform;
using Avalonia.UnitTests;

[assembly: ExportAvaloniaModule("DefaultModule", typeof(AppBuilderTests.DefaultModule))]
[assembly: ExportAvaloniaModule("RenderingModule", typeof(AppBuilderTests.Direct2DModule), ForRenderingSubsystem = "Direct2D1")]
Expand Down Expand Up @@ -65,7 +66,6 @@ public void LoadsDefaultModule()
{
ResetModuleLoadStates();
AppBuilder.Configure<App>()
.IgnoreSetupCheck()
.UseWindowingSubsystem(() => { })
.UseRenderingSubsystem(() => { })
.UseAvaloniaModules()
Expand All @@ -82,7 +82,6 @@ public void LoadsRenderingModuleWithMatchingRenderingSubsystem()
{
ResetModuleLoadStates();
var builder = AppBuilder.Configure<App>()
.IgnoreSetupCheck()
.UseWindowingSubsystem(() => { })
.UseRenderingSubsystem(() => { }, "Direct2D1");
builder.UseAvaloniaModules().SetupWithoutStarting();
Expand All @@ -92,7 +91,6 @@ public void LoadsRenderingModuleWithMatchingRenderingSubsystem()

ResetModuleLoadStates();
builder = AppBuilder.Configure<App>()
.IgnoreSetupCheck()
.UseWindowingSubsystem(() => { })
.UseRenderingSubsystem(() => { }, "Skia");
builder.UseAvaloniaModules().SetupWithoutStarting();
Expand All @@ -109,7 +107,6 @@ public void LoadsRenderingModuleWithoutDependenciesWhenNoModuleMatches()
{
ResetModuleLoadStates();
var builder = AppBuilder.Configure<App>()
.IgnoreSetupCheck()
.UseWindowingSubsystem(() => { })
.UseRenderingSubsystem(() => { }, "TBD");
builder.UseAvaloniaModules().SetupWithoutStarting();
Expand Down
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Update="**\*.xaml.cs">
Expand Down
8 changes: 8 additions & 0 deletions tests/Avalonia.DesignerSupport.Tests/DesignerSupportTests.cs
Expand Up @@ -19,6 +19,12 @@ namespace Avalonia.DesignerSupport.Tests
public class DesignerSupportTests
{
private const string DesignerAppPath = "../../../../../src/tools/Avalonia.Designer.HostApp/bin/$BUILD/netcoreapp2.0/Avalonia.Designer.HostApp.dll";
private readonly Xunit.Abstractions.ITestOutputHelper outputHelper;

public DesignerSupportTests(Xunit.Abstractions.ITestOutputHelper outputHelper)
{
this.outputHelper = outputHelper;
}

[SkippableTheory,
InlineData(
Expand Down Expand Up @@ -73,6 +79,8 @@ public class DesignerSupportTests
}
else if (msg is UpdateXamlResultMessage result)
{
if (result.Error != null)
outputHelper.WriteLine(result.Error);
handle = result.Handle != null ? long.Parse(result.Handle) : 0;
resultMessageReceivedToken.Cancel();
conn.Dispose();
Expand Down
1 change: 1 addition & 0 deletions tests/Avalonia.Layout.UnitTests/FullLayoutTests.cs
Expand Up @@ -21,6 +21,7 @@
using Avalonia.Media;
using System;
using System.Collections.Generic;
using Avalonia.UnitTests;

namespace Avalonia.Layout.UnitTests
{
Expand Down
20 changes: 2 additions & 18 deletions tests/Avalonia.UnitTests/Avalonia.UnitTests.csproj
@@ -1,22 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<Reference Include="System" />
<Reference Include="System.Core" />
<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>
<ProjectReference Condition="'$(TargetFramework)' == 'net461'" Include="..\..\src\Avalonia.DotNetFrameworkRuntime\Avalonia.DotNetFrameworkRuntime.csproj" />
<ProjectReference Condition="'$(TargetFramework)' == 'netcoreapp2.0'" Include="..\..\src\Avalonia.DotNetCoreRuntime\Avalonia.DotNetCoreRuntime.csproj" />
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup.Xaml\Avalonia.Markup.Xaml.csproj" />
<ProjectReference Include="..\..\src\Markup\Avalonia.Markup\Avalonia.Markup.csproj" />
<ProjectReference Include="..\..\src\Avalonia.Animation\Avalonia.Animation.csproj" />
Expand All @@ -29,11 +17,7 @@
<ProjectReference Include="..\..\src\Avalonia.Styling\Avalonia.Styling.csproj" />
<ProjectReference Include="..\..\src\Avalonia.Themes.Default\Avalonia.Themes.Default.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="..\..\build\Moq.props" />
<Import Project="..\..\build\Rx.props" />
<Import Project="..\..\build\XUnit.props" />
<Import Project="..\..\build\NetFX.props" />
<Import Project="..\..\src\Shared\PlatformSupport\PlatformSupport.projitems" Label="Shared" />
</Project>
16 changes: 16 additions & 0 deletions tests/Avalonia.UnitTests/RuntimeInfo.cs
@@ -0,0 +1,16 @@
using Avalonia.Platform;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace Avalonia.Shared.PlatformSupport
{
internal partial class StandardRuntimePlatform : IRuntimePlatform
{
public RuntimePlatformInfo GetRuntimeInfo()
{
return new RuntimePlatformInfo();
}
}
}
14 changes: 14 additions & 0 deletions tests/Avalonia.UnitTests/TestServices.cs
Expand Up @@ -14,6 +14,8 @@
using Avalonia.Rendering;
using System.Reactive.Concurrency;
using System.Collections.Generic;
using Avalonia.Controls;
using System.Reflection;

namespace Avalonia.UnitTests
{
Expand Down Expand Up @@ -178,4 +180,16 @@ private static IPlatformRenderInterface CreateRenderInterfaceMock()
y => y.Open() == Mock.Of<IStreamGeometryContextImpl>()));
}
}

public class AppBuilder : AppBuilderBase<AppBuilder>
{
public AppBuilder()
: base(new StandardRuntimePlatform(),
builder => StandardRuntimePlatformServices.Register(builder.Instance?.GetType()
?.GetTypeInfo().Assembly))
{
}

protected override bool CheckSetup => false;
}
}
11 changes: 0 additions & 11 deletions tests/Avalonia.UnitTests/app.config

This file was deleted.

0 comments on commit 4ec647b

Please sign in to comment.