public View(ViewModel vm) { InitializeComponent(); DataContext = vm; this.Closing += View_Closing; }
static void Main(string[] args) { AppDomain.CurrentDomain.AssemblyResolve += AssemblyHelper.CurrentDomain_AssemblyResolve; try { TestRunsComplete += Program_TestRunsComplete; if (!ParseArguments(args)) { return; } var vm = new ViewModel(); if (!FindRevit(vm.Products)) { return; } if (_gui) { LoadSettings(); if (!string.IsNullOrEmpty(_testAssembly) && File.Exists(_testAssembly)) { Refresh(vm); } // Show the user interface var view = new View(vm); view.ShowDialog(); SaveSettings(); } else { if (string.IsNullOrEmpty(_workingDirectory)) { _workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } // In any case here, the test assembly cannot be null if (string.IsNullOrEmpty(_testAssembly)) { Console.WriteLine("You must specify at least a test assembly."); return; } if (!ReadAssembly(_testAssembly, vm.Assemblies)) { return; } if (File.Exists(_results)) { File.Delete(_results); } // If fixture name and test name are specified if (string.IsNullOrEmpty(_fixture) && string.IsNullOrEmpty(_test)) { _runCount = vm.Assemblies.SelectMany(a => a.Fixtures.SelectMany(f => f.Tests)).Count(); foreach (var ad in vm.Assemblies) { RunAssembly(ad); } } // If test is not specified but fixture is specified else if (string.IsNullOrEmpty(_test) && !string.IsNullOrEmpty(_fixture)) { var fd = vm.Assemblies.SelectMany(x => x.Fixtures).FirstOrDefault(f => f.Name == _fixture); if (fd != null) { _runCount = fd.Tests.Count; RunFixture(fd); } } // If test is specified else if (string.IsNullOrEmpty(_fixture) && !string.IsNullOrEmpty(_test)) { var td = vm.Assemblies.SelectMany(a => a.Fixtures.SelectMany(f => f.Tests)) .FirstOrDefault(t => t.Name == _test); if (td != null) { _runCount = 1; RunTest(td); } } } Cleanup(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public static void Refresh(ViewModel vm) { vm.Assemblies.Clear(); ReadAssembly(_testAssembly, vm.Assemblies); }
static void Main(string[] args) { AppDomain.CurrentDomain.AssemblyResolve += AssemblyHelper.CurrentDomain_AssemblyResolve; try { TestRunsComplete += Program_TestRunsComplete; if (!ParseArguments(args)) { return; } _vm = new ViewModel(); if (!FindRevit(_vm.Products)) { return; } if (_gui) { LoadSettings(); if (!string.IsNullOrEmpty(_testAssembly) && File.Exists(_testAssembly)) { Refresh(_vm); } // Show the user interface var view = new View(_vm); view.ShowDialog(); SaveSettings(); } else { if (string.IsNullOrEmpty(_revitPath)) { _revitPath = Path.Combine(_vm.Products.First().InstallLocation, "revit.exe"); } if (string.IsNullOrEmpty(_workingDirectory)) { _workingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } // In any case here, the test assembly cannot be null if (string.IsNullOrEmpty(_testAssembly)) { Console.WriteLine("You must specify at least a test assembly."); return; } if (!ReadAssembly(_testAssembly, _vm.Assemblies)) { return; } if (File.Exists(_results) && !_concat) { File.Delete(_results); } Console.WriteLine("Assembly : {0}", _testAssembly); Console.WriteLine("Fixture : {0}", _fixture); Console.WriteLine("Test : {0}", _test); Console.WriteLine("Results Path : {0}", _results); Console.WriteLine("Timeout : {0}", _timeout); Console.WriteLine("Debug : {0}", _isDebug ? "True" : "False"); Console.WriteLine("Working Directory : {0}", _workingDirectory); Console.WriteLine("GUI : {0}", _gui ? "True" : "False"); Console.WriteLine("Revit : {0}", _revitPath); if (string.IsNullOrEmpty(_fixture) && string.IsNullOrEmpty(_test)) { _runCount = _vm.Assemblies.SelectMany(a => a.Fixtures.SelectMany(f => f.Tests)).Count(); foreach (var ad in _vm.Assemblies) { RunAssembly(ad); } } else if (string.IsNullOrEmpty(_test) && !string.IsNullOrEmpty(_fixture)) { var fd = _vm.Assemblies.SelectMany(x => x.Fixtures).FirstOrDefault(f => f.Name == _fixture); if (fd != null) { _runCount = fd.Tests.Count; RunFixture(fd); } } else if (string.IsNullOrEmpty(_fixture) && !string.IsNullOrEmpty(_test)) { var td = _vm.Assemblies.SelectMany(a => a.Fixtures.SelectMany(f => f.Tests)) .FirstOrDefault(t => t.Name == _test); if (td != null) { _runCount = 1; RunTest(td); } } } Cleanup(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }