~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/Python/PythonBinding/Test/Converter/IntegerClassFieldInitializedInConstructorTestFixture.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 System.CodeDom;
 
6
using System.CodeDom.Compiler;
 
7
using ICSharpCode.NRefactory;
 
8
using ICSharpCode.PythonBinding;
 
9
using NUnit.Framework;
 
10
 
 
11
namespace PythonBinding.Tests.Converter
 
12
{
 
13
        /// <summary>
 
14
        /// Tests the CSharpToPythonConverter correctly converts the class
 
15
        /// constructor when a value is assigned to one of its fields.
 
16
        /// </summary>
 
17
        [TestFixture]
 
18
        public class IntegerClassFieldInitializedInConstructorTestFixture
 
19
        {
 
20
                string csharp = "class Foo\r\n" +
 
21
                                                "{\r\n" +
 
22
                                                "\tprivate int i;\r\n" +
 
23
                                                "\tpublic Foo()\r\n" +
 
24
                                                "\t{\r\n" +
 
25
                                                "\t\ti = 0;\r\n" +
 
26
                                                "\t}\r\n" +
 
27
                                                "}";
 
28
                
 
29
                [Test]
 
30
                public void ConvertedPythonCode()
 
31
                {
 
32
                        NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
 
33
                        string python = converter.Convert(csharp);
 
34
                        string expectedPython = "class Foo(object):\r\n" +
 
35
                                                                        "\tdef __init__(self):\r\n" +
 
36
                                                                        "\t\tself._i = 0";
 
37
                        
 
38
                        Assert.AreEqual(expectedPython, python);
 
39
                }               
 
40
        }
 
41
}