public virtual IRemoteStoryHandler GetHandler(IEnumerable<Story> stories, IEventBus bus) { var spec = new AssemblyGenerationSpec { Assemblies = _assemblyRegistry.GetAssemblyLocations() }; foreach (var story in stories) { spec.AddStory(story, story.Scenarios); } var assemblyLocation = _assemblyGenerator.GenerateAssembly(spec); return new RemoteStoryHandler(assemblyLocation, _filesystem, bus, _assemblyRegistry.GetAssemblyLocations()); }
public virtual IRemoteStoryHandler GetHandler(IEnumerable<Story> stories, IEventBus bus) { var spec = new AssemblyGenerationSpec { Assemblies = _assemblyRegistry.GetAssemblyLocations() }; foreach (var story in stories) { spec.AddStory(story, story.Scenarios); } var assemblyLocation = _assemblyGenerator.GenerateAssembly(spec); var assembly = Assembly.LoadFrom(assemblyLocation); return new LocalHandler(Activator.CreateInstance(assembly.GetType("StorEvilTestAssembly.StorEvilDriver"), new object[] {bus}) as IStoryHandler); // return new RemoteStoryHandler(assemblyLocation, _filesystem, bus, _assemblyRegistry.GetAssemblyLocations()); }
public void SetupContext() { Generator = new AssemblyGenerator(); _scenarios = new IScenario[] { TestHelper.BuildScenario("foo", "When I do seomthing", "something else should happen") }; var spec = new AssemblyGenerationSpec {Assemblies = new[] {this.GetType().Assembly.Location}}; spec.AddStory(new Story("foo", "bar", _scenarios), _scenarios); GeneratedAssemblyPath = Generator.GenerateAssembly(spec); }
public string GetSourceCode(AssemblyGenerationSpec spec) { var driverBuilder = new StringBuilder(); var selectionBuilder = new StringBuilder(); foreach (var story in spec.Stories) { var codeBuilder = new StringBuilder(); codeBuilder.AppendLine("// " + story.Story.Id); AppendStoryCode(codeBuilder, story.Story, story.Scenarios.ToArray()); selectionBuilder.AppendFormat(_driverSelectionClause, story.Story.Id, story.Story.Id.ToCSharpMethodName()); var driverCode = string.Format(_driverTemplate, FormatStoryId(story.Story), BuildContextFactorySetup(spec.Assemblies), codeBuilder); driverBuilder.AppendLine(driverCode); } var _sourceCode = string.Format(_sourceCodeTemplate, "", driverBuilder, selectionBuilder); return(_sourceCode); }
public string GenerateAssembly(AssemblyGenerationSpec spec) { var sourceCode =_handlerGenerator.GetSourceCode(spec); return _compiler.CompileToFile(sourceCode, spec.Assemblies, GetAssemblyLocation()); }
public string GetSourceCode(AssemblyGenerationSpec spec) { var driverBuilder = new StringBuilder(); var selectionBuilder = new StringBuilder(); foreach (var story in spec.Stories) { var codeBuilder = new StringBuilder(); codeBuilder.AppendLine("// " + story.Story.Id); AppendStoryCode(codeBuilder, story.Story, story.Scenarios.ToArray()); selectionBuilder.AppendFormat(_driverSelectionClause, story.Story.Id, story.Story.Id.ToCSharpMethodName()); var driverCode = string.Format(_driverTemplate, FormatStoryId(story.Story), BuildContextFactorySetup(spec.Assemblies), codeBuilder); driverBuilder.AppendLine(driverCode); } var _sourceCode = string.Format(_sourceCodeTemplate, "", driverBuilder, selectionBuilder); return _sourceCode; }
public Assembly GenerateAssemblyInMemory(AssemblyGenerationSpec spec) { var sourceCode = _handlerGenerator.GetSourceCode(spec); return _compiler.CompileInMemory(sourceCode, spec.Assemblies); }