1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
21 using AspectSharp
.Lang
.AST
;
22 using AspectSharp
.Lang
.Steps
;
24 using NUnit
.Framework
;
27 /// Summary description for ParserTestCaseBase.
29 public abstract class ParserTestCaseBase
31 private StringBuilder messages
= new StringBuilder();
32 protected Context _context
;
35 public void ClearBuffer()
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();
58 _context
= new Context();
59 _context
.Error
+= new ErrorDelegate(OnError
);
61 chain
.Build().Process(_context
, conf
);
65 protected void OnError(LexicalInfo info
, string message
)
67 messages
.Append(message
);
71 protected virtual void AddSteps(StepChainBuilder chain
)