~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/ElseIfStatementConversionTestFixture.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.NRefactory;
 
6
using ICSharpCode.RubyBinding;
 
7
using NUnit.Framework;
 
8
 
 
9
namespace RubyBinding.Tests.Converter
 
10
{
 
11
        [TestFixture]
 
12
        public class ElseIfStatementConversionTestFixture
 
13
        {
 
14
                string csharp = "class Foo\r\n" +
 
15
                                                "{\r\n" +
 
16
                                                "    public int GetCount(i)\r\n" +
 
17
                                                "    {" +
 
18
                                                "        if (i == 0) {\r\n" +
 
19
                                                "            return 10;\r\n" +
 
20
                                                "        } else if (i < 1) {\r\n" +
 
21
                                                "            return 4;\r\n" +
 
22
                                                "        }\r\n" +
 
23
                                                "        return 2;\r\n" +
 
24
                                                "    }\r\n" +
 
25
                                                "}";
 
26
                                                
 
27
                [Test]
 
28
                public void ConvertedRubyCode()
 
29
                {
 
30
                        NRefactoryToRubyConverter converter = new NRefactoryToRubyConverter(SupportedLanguage.CSharp);
 
31
                        converter.IndentString = "    ";
 
32
                        string Ruby = converter.Convert(csharp);
 
33
                        string expectedRuby = "class Foo\r\n" +
 
34
                                                                        "    def GetCount(i)\r\n" +
 
35
                                                                        "        if i == 0 then\r\n" +
 
36
                                                                        "            return 10\r\n" +
 
37
                                                                        "        elsif i < 1 then\r\n" +
 
38
                                                                        "            return 4\r\n" +
 
39
                                                                        "        end\r\n" +
 
40
                                                                        "        return 2\r\n" +
 
41
                                                                        "    end\r\n" +
 
42
                                                                        "end";
 
43
                        
 
44
                        Assert.AreEqual(expectedRuby, Ruby);
 
45
                }
 
46
        }
 
47
}