Assembla home | Assembla project page
 

Changeset 267

Show
Ignore:
Timestamp:
09/02/08 16:31:51 (3 months ago)
Author:
olson.jeffery
Message:

added IAssemblyContext which, when implemented in an assembly container mspec tests, can have OnAssemblyStart?() and OnAssemblyEnd?() methods that will get executed at appropriate times, as their name suggests. added a FindAssemblyContextsIn?() method to AssemblyExplorer? to fetch implemented IAssemblyContext types in an assembly and added code to execute them to SpecificationRunner?.RunAssembly?()

Signed-off-by: Jeffery Olson <olson.jeffery@gmail.com>

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Source/Specifications/Machine.Specifications/Explorers/AssemblyExplorer.cs

    r157 r267  
    3030        .Where(x=>x.Namespace == targetNamespace) 
    3131        .Select(x=>CreateContextFrom(x)); 
     32    } 
     33 
     34    public IEnumerable<IAssemblyContext> FindAssemblyContextsIn(Assembly assembly) 
     35    { 
     36      return assembly.GetExportedTypes() 
     37        .Where(x => 
     38               x.GetInterfaces().Contains(typeof (IAssemblyContext))) 
     39        .Select(x => (IAssemblyContext)Activator.CreateInstance(x)); 
    3240    } 
    3341 
  • trunk/Source/Specifications/Machine.Specifications/Machine.Specifications.csproj

    r260 r267  
    5656    <Compile Include="Factories\SpecificationFactory.cs" /> 
    5757    <Compile Include="Factories\ContextFactory.cs" /> 
     58    <Compile Include="IAssemblyContext.cs" /> 
    5859    <Compile Include="Model\Concern.cs" /> 
    5960    <Compile Include="Model\ItSpecification.cs" /> 
  • trunk/Source/Specifications/Machine.Specifications/Runner/SpecificationRunner.cs

    r260 r267  
    2525      var contexts = _explorer.FindContextsIn(assembly); 
    2626 
     27      var assemblyContexts = new List<IAssemblyContext>(_explorer.FindAssemblyContextsIn(assembly)); 
     28 
     29      assemblyContexts.ForEach(assemblyContext=> 
     30        assemblyContext.OnAssemblyStart()); 
     31 
    2732      _listener.OnAssemblyStart(assembly); 
     33       
    2834      RunContexts(contexts); 
     35       
     36      assemblyContexts.ForEach(assemblyContext=> 
     37        assemblyContext.OnAssemblyComplete()); 
     38       
    2939      _listener.OnAssemblyEnd(assembly); 
    3040    }