Completing the rest of the previous commit, forgot that it changed Core as well.
[castle.git] / AspectSharp / AspectSharp.Lang.Tests / ParserImportTestCase.cs
blob20191ae5218e7b2ad7ecd5cba734d9d019dc9aac
1 // Copyright 2004-2007 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;
19 using antlr;
21 using NUnit.Framework;
23 using AspectSharp.Lang.AST;
25 /// <summary>
26 /// Summary description for ParserImportTestCase.
27 /// </summary>
28 [TestFixture]
29 public class ParserImportTestCase : ParserTestCaseBase
31 [Test]
32 public void ParsingImportDeclarations()
34 AspectParser parser = CreateParser("import my.ns.name");
35 EngineConfiguration conf = parser.Parse();
36 Assert.IsNotNull(conf);
37 Assert.IsNotNull(conf.Imports);
38 Assert.AreEqual(1, conf.Imports.Count);
39 ImportDirective import = conf.Imports[0];
40 Assert.IsNotNull(import);
41 Assert.AreEqual("my.ns.name", import.Namespace);
44 [Test]
45 public void ParsingImportDeclarationsWithAssemblies()
47 AspectParser parser = CreateParser("import my.ns.name in my.assembly.Name");
48 EngineConfiguration conf = parser.Parse();
49 Assert.IsNotNull(conf);
50 Assert.IsNotNull(conf.Imports);
51 Assert.AreEqual(1, conf.Imports.Count);
52 ImportDirective import = conf.Imports[0];
53 Assert.IsNotNull(import);
54 Assert.AreEqual("my.ns.name", import.Namespace);
55 Assert.AreEqual("my.assembly.Name", import.AssemblyReference.AssemblyName);
58 [Test]
59 public void ParsingSimpleImportDeclarations()
61 AspectParser parser = CreateParser("import my\r\nimport two");
62 EngineConfiguration conf = parser.Parse();
63 Assert.IsNotNull(conf);
64 Assert.IsNotNull(conf.Imports);
65 Assert.AreEqual(2, conf.Imports.Count);
66 ImportDirective import = conf.Imports[0];
67 Assert.IsNotNull(import);
68 Assert.AreEqual("my", import.Namespace);
69 import = conf.Imports[1];
70 Assert.IsNotNull(import);
71 Assert.AreEqual("two", import.Namespace);
74 [Test]
75 [ExpectedException(typeof(MismatchedTokenException))]
76 public void InvalidImportDeclaration()
78 AspectParser parser = CreateParser("import \r\nimport \r\n");
79 parser.Parse();