|
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/>
// <version>$Revision: 1609 $</version>
// </file>
using System;
using ICSharpCode.NRefactory.Ast;
using NUnit.Framework;
namespace ICSharpCode.NRefactory.Tests.Ast
{
[TestFixture]
public class NamespaceDeclarationTests
{
#region C#
[Test]
public void CSharpSimpleNamespaceTest()
{
string program = "namespace TestNamespace {\n" +
"}\n";
NamespaceDeclaration ns = ParseUtilCSharp.ParseGlobal<NamespaceDeclaration>(program);
Assert.AreEqual("TestNamespace", ns.Name);
}
[Test]
public void CSharpJuggedNamespaceTest()
{
string program = "namespace N1 {//TestNamespace\n" +
" namespace N2 {// Declares a namespace named N2 within N1.\n" +
" }\n" +
"}\n";
NamespaceDeclaration ns = ParseUtilCSharp.ParseGlobal<NamespaceDeclaration>(program);
Assert.AreEqual("N1", ns.Name);
Assert.IsTrue(ns.Children[0] is NamespaceDeclaration);
ns = (NamespaceDeclaration)ns.Children[0];
Assert.AreEqual("N2", ns.Name);
}
#endregion
#region VB.NET
[Test]
public void VBNetSimpleNamespaceTest()
{
string program = "Namespace TestNamespace" + Environment.NewLine +
"End Namespace" +Environment.NewLine;
NamespaceDeclaration ns = ParseUtilVBNet.ParseGlobal<NamespaceDeclaration>(program);
Assert.AreEqual("TestNamespace", ns.Name);
}
[Test]
public void VBNetJuggedNamespaceTest()
{
string program = "Namespace N1 'TestNamespace\n" +
" Namespace N2 ' Declares a namespace named N2 within N1.\n" +
" End Namespace\n" +
"End Namespace\n";
NamespaceDeclaration ns = ParseUtilVBNet.ParseGlobal<NamespaceDeclaration>(program);
Assert.AreEqual("N1", ns.Name);
Assert.IsTrue(ns.Children[0] is NamespaceDeclaration);
ns = (NamespaceDeclaration)ns.Children[0];
Assert.AreEqual("N2", ns.Name);
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.