~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/Python/PythonBinding/Test/Parsing/ParseClassNestedInsideMethodTestFixture.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using ICSharpCode.PythonBinding;
 
6
using ICSharpCode.SharpDevelop.Dom;
 
7
using NUnit.Framework;
 
8
 
 
9
namespace PythonBinding.Tests.Parsing
 
10
{
 
11
        [TestFixture]
 
12
        public class ParseClassNestedInsideMethodTestFixture
 
13
        {
 
14
                ICompilationUnit compilationUnit;
 
15
                IClass c;
 
16
                
 
17
                [SetUp]
 
18
                public void SetUpFixture()
 
19
                {
 
20
                        string python =
 
21
                                "class MyClass:\r\n" +
 
22
                                "    def firstMethod(self):\r\n" +
 
23
                                "        class NestedClass:\r\n" +
 
24
                                "            def firstNestedClassMethod(self):\r\n" +
 
25
                                "                pass\r\n" +
 
26
                                "\r\n" +
 
27
                                "    def secondMethod(self):\r\n" +
 
28
                                "        pass\r\n" +
 
29
                                "\r\n";
 
30
                        
 
31
                        DefaultProjectContent projectContent = new DefaultProjectContent();
 
32
                        PythonParser parser = new PythonParser();
 
33
                        compilationUnit = parser.Parse(projectContent, @"C:\test.py", python);
 
34
                        if (compilationUnit.Classes.Count > 0) {
 
35
                                c = compilationUnit.Classes[0];
 
36
                        }
 
37
                }
 
38
                
 
39
                [Test]
 
40
                public void CompilationUnitHasOneClass()
 
41
                {
 
42
                        Assert.AreEqual(1, compilationUnit.Classes.Count);
 
43
                }
 
44
                
 
45
                [Test]
 
46
                public void MyClassHasTwoMethods()
 
47
                {
 
48
                        Assert.AreEqual(2, c.Methods.Count);
 
49
                }
 
50
        }
 
51
}