~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/PropertyConversionTestFixture.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
        /// <summary>
 
12
        /// Tests the CSharpToRubyConverter class can convert a C# property to
 
13
        /// two get and set methods in Ruby.
 
14
        /// </summary>
 
15
        [TestFixture]
 
16
        public class PropertyConversionTestFixture
 
17
        {       
 
18
                string csharp = "class Foo\r\n" +
 
19
                                                "{\r\n" +
 
20
                                                "    int count = 0;\r\n" +
 
21
                                                "    public int Count\r\n" +
 
22
                                                "    {\r\n" +
 
23
                                                "        get { return count; }\r\n" +
 
24
                                                "        set { count = value; }\r\n" +
 
25
                                                "    }\r\n" +
 
26
                                                "\r\n" +
 
27
                                                "    public void Run()\r\n" +
 
28
                                                "    {\r\n" +
 
29
                                                "    }\r\n" +
 
30
                                                "}";
 
31
                        
 
32
                [Test]
 
33
                public void ConvertedRubyCode()
 
34
                {
 
35
                        NRefactoryToRubyConverter converter = new NRefactoryToRubyConverter(SupportedLanguage.CSharp);
 
36
                        converter.IndentString = "    ";
 
37
                        string Ruby = converter.Convert(csharp);
 
38
                        string expectedRuby =
 
39
                                "class Foo\r\n" +
 
40
                                "    def initialize()\r\n" +
 
41
                                "        @count = 0\r\n" +
 
42
                                "    end\r\n" +
 
43
                                "\r\n" +
 
44
                                "    def Count\r\n" +
 
45
                                "        return @count\r\n" +
 
46
                                "    end\r\n" +
 
47
                                "\r\n" +
 
48
                                "    def Count=(value)\r\n" +
 
49
                                "        @count = value\r\n" +
 
50
                                "    end\r\n" +
 
51
                                "\r\n" +
 
52
                                "    def Run()\r\n" +
 
53
                                "    end\r\n" +
 
54
                                "end";
 
55
                                                                                        
 
56
                        Assert.AreEqual(expectedRuby, Ruby);
 
57
                }       
 
58
        }
 
59
}