-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from picoe/curtis/unit-test
Unit Test GUI
- Loading branch information
Showing
62 changed files
with
3,955 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace Eto.UnitTest.App | ||
{ | ||
class AppDomainTestRunnerWrapper : MarshalByRefObject | ||
{ | ||
ITestRunner _runner; | ||
public bool IsRunning => _runner.IsRunning; | ||
|
||
public ITest Test => _runner.TestSuite; | ||
|
||
public event EventHandler<UnitTestLogEventArgs> Log; | ||
public event EventHandler<UnitTestProgressEventArgs> Progress; | ||
public event EventHandler<UnitTestResultEventArgs> TestFinished; | ||
public event EventHandler<UnitTestTestEventArgs> TestStarted; | ||
public event EventHandler<EventArgs> IsRunningChanged; | ||
|
||
public async Task<IEnumerable<string>> GetCategories(ITestFilter filter) | ||
{ | ||
var categories = await _runner.GetCategories(filter); | ||
return categories.ToList(); | ||
} | ||
|
||
public Task<int> GetTestCount(ITestFilter filter) | ||
{ | ||
return _runner.GetTestCount(filter); | ||
} | ||
|
||
public Task<ITestResult> RunAsync(ITestFilter filter) | ||
{ | ||
return _runner.RunAsync(filter); | ||
} | ||
|
||
public void StopTests() => _runner.StopTests(); | ||
|
||
public void CreateRunner(Type type) | ||
{ | ||
var runnerType = Activator.CreateInstance(type) as ITestRunnerType; | ||
_runner = runnerType.CreateRunner(); | ||
} | ||
|
||
public Task Load(ITestSource source) => _runner.Load(source); | ||
} | ||
|
||
public class AppDomainTestRunner : ITestRunner, IDisposable | ||
{ | ||
AppDomainTestRunnerWrapper _wrapper; | ||
public bool IsRunning => _wrapper.IsRunning; | ||
|
||
public ITest TestSuite => _wrapper.Test; | ||
|
||
public event EventHandler<UnitTestLogEventArgs> Log; | ||
public event EventHandler<UnitTestProgressEventArgs> Progress; | ||
public event EventHandler<UnitTestResultEventArgs> TestFinished; | ||
public event EventHandler<UnitTestTestEventArgs> TestStarted; | ||
public event EventHandler<EventArgs> IsRunningChanged; | ||
|
||
public AppDomainTestRunner() | ||
{ | ||
_wrapper = Domain.CreateInstanceFromAndUnwrap(typeof(AppDomainTestRunnerWrapper).Assembly.CodeBase, typeof(AppDomainTestRunnerWrapper).FullName) as AppDomainTestRunnerWrapper; | ||
} | ||
|
||
public void Initialize(Type runnerType) | ||
{ | ||
_wrapper.CreateRunner(runnerType); | ||
} | ||
|
||
AppDomain _domain; | ||
|
||
AppDomain Domain | ||
{ | ||
get | ||
{ | ||
if (_domain != null) | ||
return _domain; | ||
|
||
var cur = AppDomain.CurrentDomain; | ||
var si = cur.SetupInformation; | ||
//var path = AssemblyPath; | ||
var setup = new AppDomainSetup | ||
{ | ||
ApplicationName = si.ApplicationName ?? "Eto.UnitTest", | ||
CachePath = si.CachePath, | ||
ShadowCopyFiles = "true",//si.ShadowCopyFiles, | ||
ShadowCopyDirectories = si.ShadowCopyDirectories, | ||
PrivateBinPath = si.PrivateBinPath, | ||
//DynamicBase = si.DynamicBase, | ||
TargetFrameworkName = si.TargetFrameworkName, | ||
ConfigurationFile = si.ConfigurationFile, | ||
ApplicationBase = si.ApplicationBase, | ||
LoaderOptimization = LoaderOptimization.MultiDomain,//= si.LoaderOptimization, | ||
//SandboxInterop = si.SandboxInterop | ||
}; | ||
//setup.SetCompatibilitySwitches(new[] { "NetFx40_LegacySecurityPolicy" }); | ||
_domain = AppDomain.CreateDomain("UnitTests");//, cur.Evidence, setup); | ||
cur.DomainUnload += (sender, e) => UnloadDomain(); | ||
return _domain; | ||
} | ||
} | ||
|
||
public Task<IEnumerable<string>> GetCategories(ITestFilter filter) | ||
{ | ||
return _wrapper.GetCategories(filter); | ||
} | ||
|
||
public Task<int> GetTestCount(ITestFilter filter) | ||
{ | ||
return _wrapper.GetTestCount(filter); | ||
} | ||
|
||
public Task<ITestResult> RunAsync(ITestFilter filter) | ||
{ | ||
return _wrapper.RunAsync(filter); | ||
} | ||
|
||
public void StopTests() | ||
{ | ||
_wrapper.StopTests(); | ||
} | ||
|
||
void UnloadDomain() | ||
{ | ||
if (_domain == null) | ||
return; | ||
|
||
AppDomain.Unload(_domain); | ||
_domain = null; | ||
} | ||
|
||
public void Dispose() => UnloadDomain(); | ||
|
||
public Task Load(ITestSource source) => _wrapper.Load(source); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<Project> | ||
|
||
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" /> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net461</TargetFramework> | ||
<IsPackable>False</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup Condition="$(EtoBasePath) == ''"> | ||
<PackageReference Include="Eto.Forms" Version="2.5.0-rc.4" /> | ||
<PackageReference Include="Eto.Platform.Wpf" Version="2.5.0-rc.4" /> | ||
<PackageReference Include="Eto.Platform.Mac64" Version="2.5.0-rc.4" /> | ||
<PackageReference Include="Eto.Platform.Gtk" Version="2.5.0-rc.4" /> | ||
</ItemGroup> | ||
<ItemGroup Condition="$(EtoBasePath) != ''"> | ||
<ProjectReference Include="$(EtoBasePath)src\Eto\Eto.csproj" /> | ||
<ProjectReference Include="$(EtoBasePath)src\Eto.Mac\Eto.Mac64.csproj" /> | ||
<ProjectReference Include="$(EtoBasePath)src\Eto.Gtk\Eto.Gtk.csproj" /> | ||
<ProjectReference Include="$(EtoBasePath)src\Eto.Wpf\Eto.Wpf.csproj" Condition="$(OS) == 'Windows_NT'" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Eto.UnitTest\Eto.UnitTest.csproj" /> | ||
<ProjectReference Include="..\Eto.UnitTest.NUnit\Eto.UnitTest.NUnit.csproj" /> | ||
<ProjectReference Include="..\Eto.UnitTest.Xunit\Eto.UnitTest.Xunit.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.20071.2" /> | ||
</ItemGroup> | ||
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" /> | ||
|
||
<Import Condition="$(EtoBasePath) != ''" Project="$(EtoBasePath)build\Common.Mac.targets" /> | ||
</Project> |
Oops, something went wrong.