public void Run(Assembly assembly, IEnumerable<Context> contexts) { var hasExecutableSpecifications = contexts.Any(x => x.HasExecutableSpecifications); var explorer = new AssemblyExplorer(); var globalCleanups = explorer.FindAssemblyWideContextCleanupsIn(assembly).ToList(); var specificationSupplements = explorer.FindSpecificationSupplementsIn(assembly).ToList(); try { if (hasExecutableSpecifications) { _assemblyStart(assembly); } foreach (var context in contexts) { RunContext(context, globalCleanups, specificationSupplements); } } catch (Exception err) { _listener.OnFatalError(new ExceptionResult(err)); } finally { if (hasExecutableSpecifications) { _assemblyEnd(assembly); } } }
Test GetAssemblyTest(IAssemblyInfo assembly, Test parentTest, Version frameworkVersion, bool populateRecursively) { MachineAssemblyTest assemblyTest; if (!assemblyTests.TryGetValue(assembly, out assemblyTest)) { assemblyTest = new MachineAssemblyTest(assembly.Name, assembly, frameworkVersion); assemblyTest.Kind = TestKinds.Assembly; ModelUtils.PopulateMetadataFromAssembly(assembly, assemblyTest.Metadata); string frameworkName = String.Format("Machine Specifications v{0}", frameworkVersion); assemblyTest.Metadata.SetValue(MetadataKeys.Framework, frameworkName); assemblyTest.Metadata.SetValue(MetadataKeys.File, assembly.Path); assemblyTest.Kind = TestKinds.Assembly; parentTest.AddChild(assemblyTest); assemblyTests.Add(assembly, assemblyTest); } if (populateRecursively) { AssemblyExplorer explorer = new AssemblyExplorer(); Assembly resolvedAssembly = assembly.Resolve(false); assemblyTest.AssemblyContexts = explorer.FindAssemblyContextsIn( resolvedAssembly).ToList(); assemblyTest.GlobalCleanup = explorer.FindAssemblyWideContextCleanupsIn(resolvedAssembly).ToList(); assemblyTest.SpecificationSupplements = explorer.FindSpecificationSupplementsIn(resolvedAssembly).ToList(); explorer.FindContextsIn(resolvedAssembly) .Select( context => GetContextTest( context)) .Each( test => assemblyTest.AddChild( test)); } return assemblyTest; }