public override void MainSetup() { base.MainSetup(); var generator = new pMixinPartialCodeGenerator(); var context = Kernel.Get<ICodeGeneratorContextFactory>() .GenerateContext( Solution.AllFiles .Where(f => f.FileName.FullPath.EndsWith("ExistingMixinFileTest.cs"))) .First(); _response = generator.GeneratePartialCode(context); }
public override void MainSetup() { base.MainSetup(); var generator = new pMixinPartialCodeGenerator(); var context = Kernel.Get <ICodeGeneratorContextFactory>() .GenerateContext( Solution.AllFiles .Where(f => f.FileName.FullPath.EndsWith("ExistingMixinFileTest.cs"))) .First(); _response = generator.GeneratePartialCode(context); }
public override void MainSetup() { base.MainSetup(); Console.WriteLine("SourceCode: \n\n"+ SourceCode + "\n"); var generator = new pMixinPartialCodeGenerator(); try { CodeGeneratorContextFactory = Kernel.Get<ICodeGeneratorContextFactory>(); Assert.NotNull(CodeGeneratorContextFactory, "Kernel returned a null ICodeGeneratorContextFactory."); CodeGenerationContext = CodeGeneratorContextFactory .GenerateContext( new []{ new RawSourceFile { FileContents = SourceCode, FileName = new FilePath(@"c:\testing\testFile.cs"), ProjectFileName = ProjectFile }}) .First(); } catch(Exception e) { Log.Fatal(e); Assert.Fail("Exception in CodeGeneratorContextFactory: " + e.Message, e); } try { Response = generator.GeneratePartialCode(CodeGenerationContext); } catch (Exception e) { Exception = e; if (!ExpectException) Assert.Fail("Encountered an unexpected exception: " + e.Message, e); } if (Response.Errors.Any()) { Console.WriteLine("Generator Errors: \n\n"); Console.WriteLine( string.Join("\r\n", Response.Errors.Select(e => e.Message))); Console.WriteLine("\n"); } GeneratedCode = Response.GeneratedCodeSyntaxTree.GetText(); Console.WriteLine("Generated: \n\n " + GeneratedCode + "\n"); }
public override void MainSetup() { base.MainSetup(); Console.WriteLine("SourceCode: \n\n" + SourceCode + "\n"); var generator = new pMixinPartialCodeGenerator(); try { CodeGeneratorContextFactory = Kernel.Get <ICodeGeneratorContextFactory>(); Assert.NotNull(CodeGeneratorContextFactory, "Kernel returned a null ICodeGeneratorContextFactory."); CodeGenerationContext = CodeGeneratorContextFactory .GenerateContext( new [] { new RawSourceFile { FileContents = SourceCode, FileName = new FilePath(@"c:\testing\testFile.cs"), ProjectFileName = ProjectFile } }) .First(); } catch (Exception e) { Log.Fatal(e); Assert.Fail("Exception in CodeGeneratorContextFactory: " + e.Message, e); } try { Response = generator.GeneratePartialCode(CodeGenerationContext); } catch (Exception e) { Exception = e; if (!ExpectException) { Assert.Fail("Encountered an unexpected exception: " + e.Message, e); } } if (Response.Errors.Any()) { Console.WriteLine("Generator Errors: \n\n"); Console.WriteLine( string.Join("\r\n", Response.Errors.Select(e => e.Message))); Console.WriteLine("\n"); } GeneratedCode = Response.GeneratedCodeSyntaxTree.GetText(); Console.WriteLine("Generated: \n\n " + GeneratedCode + "\n"); }