added config
This commit is contained in:
+3
-3
@@ -26,10 +26,10 @@ namespace xUnitRevit
|
||||
Application app = sender as Application;
|
||||
UIApplication uiapp = new UIApplication(app);
|
||||
|
||||
|
||||
Runner.ReadConfig();
|
||||
|
||||
// uiapp.OpenAndActivateDocument(@"C:\Code\Speckle-Next\SpeckleKitRevit\TestModels\Walls.rvt");
|
||||
TestRunner.Launch(uiapp);
|
||||
if(Runner.Config.autoStart)
|
||||
Runner.Launch(uiapp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace xUnitRevit
|
||||
ElementSet elements)
|
||||
{
|
||||
UIApplication uiapp = commandData.Application;
|
||||
TestRunner.Launch(uiapp);
|
||||
Runner.Launch(uiapp);
|
||||
return Result.Succeeded;
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace xUnitRevit
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple configuration file for lazy developers
|
||||
/// </summary>
|
||||
public class Configuration
|
||||
{
|
||||
public List<string> startupAssemblies { get; set; } = new List<string>();
|
||||
public bool autoStart { get; set; } = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using Autodesk.Revit.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit.Runner.Wpf;
|
||||
using Xunit.Runner.Wpf.ViewModel;
|
||||
using xUnitRevitUtils;
|
||||
using System.Web.Script.Serialization;
|
||||
using System.IO;
|
||||
|
||||
namespace xUnitRevit
|
||||
{
|
||||
public static class Runner
|
||||
{
|
||||
internal static Configuration Config = new Configuration();
|
||||
internal static void Launch(UIApplication uiapp)
|
||||
{
|
||||
try
|
||||
{
|
||||
var queue = new List<Action>();
|
||||
var eventHandler = ExternalEvent.Create(new ExternalEventHandler(queue));
|
||||
|
||||
xru.Initialize(uiapp, SynchronizationContext.Current, eventHandler, queue);
|
||||
|
||||
var main = new MainWindow();
|
||||
main.Title = "xUnit Revit by Speckle";
|
||||
|
||||
//pre-load asssemblies, if you're a lazy developer
|
||||
(main.DataContext as MainViewModel).StartupAssemblies = Config.startupAssemblies;
|
||||
main.Show();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//fail silently
|
||||
}
|
||||
}
|
||||
|
||||
internal static void ReadConfig()
|
||||
{
|
||||
try
|
||||
{
|
||||
var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
var path = Path.Combine(dir, "config.json");
|
||||
JavaScriptSerializer JavaScriptSerializer = new JavaScriptSerializer();
|
||||
var json = File.ReadAllText(path);
|
||||
Config = JavaScriptSerializer.Deserialize<Configuration>(json);
|
||||
}
|
||||
catch
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
using Autodesk.Revit.UI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit.Runner.Wpf;
|
||||
using Xunit.Runner.Wpf.ViewModel;
|
||||
using xUnitRevitUtils;
|
||||
|
||||
namespace xUnitRevit
|
||||
{
|
||||
public static class TestRunner
|
||||
{
|
||||
public static void Launch(UIApplication uiapp)
|
||||
{
|
||||
try
|
||||
{
|
||||
var queue = new List<Action>();
|
||||
var eventHandler = ExternalEvent.Create(new ExternalEventHandler(queue));
|
||||
|
||||
xru.Initialize(uiapp, SynchronizationContext.Current, eventHandler, queue);
|
||||
|
||||
var main = new MainWindow();
|
||||
main.Title = "xUnit Revit by Speckle";
|
||||
/// (main.DataContext as MainViewModel).Injector =
|
||||
(main.DataContext as MainViewModel).StartupAssemblies = new List<string>() { @"C:\Code\Speckle-Next\SpeckleKitRevit\SpeckleRevitTests\bin\Debug\SpeckleRevitTests.dll" };
|
||||
main.Show();
|
||||
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
//return Result.Succeeded;
|
||||
}
|
||||
}
|
||||
|
||||
//public class Injector : IAssemblyInjector
|
||||
//{
|
||||
// private UIApplication uiapp { get; set; }
|
||||
// SynchronizationContext uiContext { get; set; }
|
||||
|
||||
// private List<Action> queue { get; set; }
|
||||
// private ExternalEvent eventHandler { get; set; }
|
||||
|
||||
// public Injector(UIApplication uiapp, SynchronizationContext uiContext, ExternalEvent eventHandler, List<Action> queue)
|
||||
// {
|
||||
// this.uiapp = uiapp;
|
||||
// this.uiContext = uiContext;
|
||||
// this.eventHandler = eventHandler;
|
||||
// this.queue = queue;
|
||||
// }
|
||||
// public void Inject(Assembly assembly)
|
||||
// {
|
||||
// var types = assembly.GetTypes();
|
||||
// foreach (var type in types)
|
||||
// {
|
||||
// if (type.Name == "xru")
|
||||
// {
|
||||
// if (type.GetProperties().Select(p => p.Name).Contains("Uiapp"))
|
||||
// {
|
||||
// type.GetProperty("Uiapp").SetValue(null, uiapp);
|
||||
// type.GetProperty("UiContext").SetValue(null, uiContext);
|
||||
// type.GetProperty("Queue").SetValue(null, queue);
|
||||
// type.GetProperty("EventHandler").SetValue(null, eventHandler);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.6.0" newVersion="4.0.6.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.ValueTuple" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"startupAssemblies": [
|
||||
"C:\\Code\\Speckle-Next\\SpeckleKitRevit\\SpeckleRevitTests\\bin\\Debug\\SpeckleRevitTests.dll"
|
||||
],
|
||||
"autoStart": true
|
||||
}
|
||||
@@ -55,17 +55,24 @@
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Web.Extensions" />
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App.cs" />
|
||||
<Compile Include="CmdAvailabilityViews.cs" />
|
||||
<Compile Include="Command.cs" />
|
||||
<Compile Include="Config.cs" />
|
||||
<Compile Include="ExternalEventHandler.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="TestRunner.cs" />
|
||||
<Compile Include="Runner.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="config.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="packages.config" />
|
||||
<None Include="xUnitRevit.addin" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
+1
-1
Submodule xunit.runner.wpf updated: 2365885ffa...8041093761
Reference in New Issue
Block a user