This repository has been archived by the owner on Oct 16, 2020. It is now read-only.
/
ForNextConversionTests.cs
74 lines (67 loc) · 2.21 KB
/
ForNextConversionTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.NRefactory;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
namespace PythonBinding.Tests.Converter
{
[TestFixture]
public class ForNextConversionTests
{
string vbnetForNextCode =
"Public Class Foo\r\n" +
" Public Function GetCount() As Integer\r\n" +
" Dim count As Integer = 0\r\n" +
" For i As Integer = 0 To 4\r\n" +
" count += 1\r\n" +
" Next\r\n" +
" Return count\r\n" +
" End Function\r\n" +
"End Class\r\n";
[Test]
public void ConvertVBNetForNextToPython()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.VBNet);
converter.IndentString = " ";
string code = converter.Convert(vbnetForNextCode);
string expectedCode =
"class Foo(object):\r\n" +
" def GetCount(self):\r\n" +
" count = 0\r\n" +
" i = 0\r\n" +
" while i <= 4:\r\n" +
" count += 1\r\n" +
" i = i + 1\r\n" +
" return count";
Assert.AreEqual(expectedCode, code);
}
string vbnetForNextWithStepCode =
"Public Class Foo\r\n" +
" Public Function GetCount() As Integer\r\n" +
" Dim count As Integer = 0\r\n" +
" For i As Integer = 0 To 4 Step 2\r\n" +
" count += 1\r\n" +
" Next\r\n" +
" Return count\r\n" +
" End Function\r\n" +
"End Class\r\n";
[Test]
public void ConvertVBNetForNextWithStepToPython()
{
NRefactoryToPythonConverter converter = new NRefactoryToPythonConverter(SupportedLanguage.VBNet);
converter.IndentString = " ";
string code = converter.Convert(vbnetForNextWithStepCode );
string expectedCode =
"class Foo(object):\r\n" +
" def GetCount(self):\r\n" +
" count = 0\r\n" +
" i = 0\r\n" +
" while i <= 4:\r\n" +
" count += 1\r\n" +
" i = i + 2\r\n" +
" return count";
Assert.AreEqual(expectedCode, code);
}
}
}