Fixing an issue with output parameters that are of type IntPtr
[castle.git] / AspectSharp / AspectSharp.Lang.Tests / ParserTestCaseBase.cs
blob2b16010bf0771e2ef5417850809437139a1abc6c
1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace AspectSharp.Lang.Tests
17 using System;
18 using System.IO;
19 using System.Text;
21 using AspectSharp.Lang.AST;
22 using AspectSharp.Lang.Steps;
24 using NUnit.Framework;
26 /// <summary>
27 /// Summary description for ParserTestCaseBase.
28 /// </summary>
29 public abstract class ParserTestCaseBase
31 private StringBuilder messages = new StringBuilder();
32 protected Context _context;
34 [SetUp]
35 public void ClearBuffer()
37 messages.Length = 0;
40 protected AspectParser CreateParser(String content)
42 StringReader reader = new StringReader(content);
43 return new AspectParser(new AspectLanguageLexer(reader));
46 protected void AssertOutput(String expected)
48 Assert.AreEqual( expected, messages.ToString() );
51 protected EngineConfiguration ProcessContent(string content)
53 EngineConfiguration conf = CreateParser( content ).Parse();
55 StepChainBuilder chain = new StepChainBuilder();
56 AddSteps(chain);
58 _context = new Context();
59 _context.Error += new ErrorDelegate(OnError);
61 chain.Build().Process(_context, conf);
62 return conf;
65 protected void OnError(LexicalInfo info, string message)
67 messages.Append(message);
68 messages.Append(';');
71 protected virtual void AddSteps(StepChainBuilder chain)