~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/Python/PythonBinding/Test/Resolver/ResolveLocalVariableMethodTests.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.SharpDevelop.Dom;
 
6
using NUnit.Framework;
 
7
using PythonBinding.Tests.Utils;
 
8
using UnitTesting.Tests.Utils;
 
9
 
 
10
namespace PythonBinding.Tests.Resolver
 
11
{
 
12
        [TestFixture]
 
13
        public class ResolveLocalVariableMethodTests
 
14
        {
 
15
                PythonResolverTestsHelper resolverHelper;
 
16
                MockClass myClass;
 
17
                
 
18
                void CreateClassWithOneProperty()
 
19
                {
 
20
                        resolverHelper = new PythonResolverTestsHelper();
 
21
                        myClass = resolverHelper.CreateClass("MyClass");
 
22
                        myClass.AddMethod("MyMethod");
 
23
                        
 
24
                        resolverHelper.ProjectContent.SetClassToReturnFromGetClass("MyClass", myClass);
 
25
                }
 
26
                
 
27
                [Test]
 
28
                public void Resolve_ExpressionIsForMethodOnLocalVariable_MethodGroupResolveResultNameIsMethodName()
 
29
                {
 
30
                        CreateClassWithOneProperty();
 
31
                        string code =
 
32
                                "a = MyClass()\r\n" +
 
33
                                "a.MyMethod";
 
34
                        
 
35
                        resolverHelper.Resolve("a.MyMethod", code);
 
36
                        string methodName = resolverHelper.MethodGroupResolveResult.Name;
 
37
                        string expectedMethodName = "MyMethod";
 
38
                        
 
39
                        Assert.AreEqual(expectedMethodName, methodName);
 
40
                }
 
41
                
 
42
                [Test]
 
43
                public void Resolve_ExpressionIsForMethodOnLocalVariable_MethodGroupResolveResultContainingTypeUnderlyingClassIsMyClass()
 
44
                {
 
45
                        CreateClassWithOneProperty();
 
46
                        string code =
 
47
                                "a = MyClass()\r\n" +
 
48
                                "a.MyMethod";
 
49
                        
 
50
                        resolverHelper.Resolve("a.MyMethod", code);
 
51
                        IClass c = resolverHelper.MethodGroupResolveResult.ContainingType.GetUnderlyingClass();
 
52
                        
 
53
                        Assert.AreEqual(myClass, c);
 
54
                }
 
55
        }
 
56
}