public IEnumerable<MSpecTestCase> DiscoverTests(string assemblyPath) { AssemblyExplorer assemblyExplorer = new AssemblyExplorer(); Assembly assembly = Assembly.LoadFile(assemblyPath); IEnumerable<Context> contexts = assemblyExplorer.FindContextsIn(assembly); return contexts.SelectMany(context => CreateTestCase(context, assemblyPath)).ToList(); }
public void SendToVisualStudio(Assembly assembly) { if (sink == null) { return; } var explorer = new AssemblyExplorer(); var contexts = explorer.FindContextsIn(assembly); foreach (var context in contexts) { foreach (var test in ConvertToVisualStudioTests(context)) { sink?.SendTest(test); } } }
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; }
public IEnumerable<Context> GetContexts(Assembly assembly) { var explorer = new AssemblyExplorer(); var contexts = explorer.FindContextsIn(assembly); return contexts; }