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)
5
using ICSharpCode.NRefactory;
6
using ICSharpCode.PythonBinding;
9
namespace PythonBinding.Tests.Converter
12
public class MultipleFieldsOnSameLineTests
14
string csharpClassWithFieldsThatHaveInitialValues =
17
" int i = 0, j = 1;\r\n" +
21
public void ConvertCSharpClassWithFieldsThatHaveInitialValues()
23
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
24
converter.IndentString = " ";
25
string python = converter.Convert(csharpClassWithFieldsThatHaveInitialValues);
26
string expectedPython =
27
"class Foo(object):\r\n" +
28
" def __init__(self):\r\n" +
32
Assert.AreEqual(expectedPython, python);
35
string csharpClassWithTwoFieldsWhereFirstDoesNotHaveInitialValue =
38
" int i, j = 1;\r\n" +
42
public void ConvertCSharpClassWithFieldsWhereFirstFieldDoesNotHaveInitialValue()
44
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
45
converter.IndentString = " ";
46
string python = converter.Convert(csharpClassWithTwoFieldsWhereFirstDoesNotHaveInitialValue);
47
string expectedPython =
48
"class Foo(object):\r\n" +
49
" def __init__(self):\r\n" +
52
Assert.AreEqual(expectedPython, python);
55
string csharpClassWithTwoFieldsInitializedInMethod =
61
" public void Test()\r\n" +
69
public void ConvertCSharpClassWithTwoFieldsInitializedInMethod()
71
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.CSharp);
72
converter.IndentString = " ";
73
string python = converter.Convert(csharpClassWithTwoFieldsInitializedInMethod);
74
string expectedPython =
75
"class Foo(object):\r\n" +
76
" def __init__(self):\r\n" +
79
" def Test(self):\r\n" +
83
Assert.AreEqual(expectedPython, python);
86
string vnetClassWithTwoArrayFieldsOnSameLine =
88
" Private i(10), j(20) as integer\r\n" +
92
public void ConvertVBNetClassWithTwoArrayFieldsOnSameLine()
94
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.VBNet);
95
converter.IndentString = " ";
96
string python = converter.Convert(vnetClassWithTwoArrayFieldsOnSameLine);
97
string expectedPython =
98
"class Foo(object):\r\n" +
99
" def __init__(self):\r\n" +
100
" self._i = Array.CreateInstance(int, 10)\r\n" +
101
" self._j = Array.CreateInstance(int, 20)";
103
Assert.AreEqual(expectedPython, python);