~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/ObjectCreationTestFixture.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 that C# code that creates a new XmlDocument object
 
13
        /// is converted to Ruby correctly.
 
14
        /// </summary>
 
15
        [TestFixture]
 
16
        public class ObjectCreationTestFixture
 
17
        {       
 
18
                string csharp = "class Foo\r\n" +
 
19
                                        "{\r\n" +
 
20
                                        "    public Foo()\r\n" +
 
21
                                        "    {\r\n" +
 
22
                                        "        XmlDocument doc = new XmlDocument();\r\n" +
 
23
                                        "        doc.LoadXml(\"<root/>\");\r\n" +
 
24
                                        "    }\r\n" +
 
25
                                        "}";
 
26
                
 
27
                [Test]
 
28
                public void ConvertedRubyCode()
 
29
                {
 
30
                        string expectedRuby =
 
31
                                "class Foo\r\n" +
 
32
                                "    def initialize()\r\n" +
 
33
                                "        doc = XmlDocument.new()\r\n" +
 
34
                                "        doc.LoadXml(\"<root/>\")\r\n" +
 
35
                                "    end\r\n" +
 
36
                                "end";
 
37
                        
 
38
                        NRefactoryToRubyConverter converter = new NRefactoryToRubyConverter(SupportedLanguage.CSharp);
 
39
                        converter.IndentString = "    ";
 
40
                        string Ruby = converter.Convert(csharp);
 
41
                        
 
42
                        Assert.AreEqual(expectedRuby, Ruby);
 
43
                }
 
44
        }
 
45
}