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.RubyBinding;
9
namespace RubyBinding.Tests.Converter
12
/// Converts a C# try-catch-finally to Ruby.
15
public class TryCatchFinallyConversionTestFixture
17
string csharp = "class Loader\r\n" +
19
" public void load(string xml)\r\n" +
22
" XmlDocument doc = new XmlDocument();\r\n" +
23
" doc.LoadXml(xml);\r\n" +
24
" } catch (XmlException ex) {\r\n" +
25
" Console.WriteLine(ex.ToString());\r\n" +
27
" Console.WriteLine(xml);\r\n" +
33
public void ConvertedCode()
37
" def load(xml)\r\n" +
39
" doc = XmlDocument.new()\r\n" +
40
" doc.LoadXml(xml)\r\n" +
41
" rescue XmlException => ex\r\n" +
42
" Console.WriteLine(ex.ToString())\r\n" +
44
" Console.WriteLine(xml)\r\n" +
49
NRefactoryToRubyConverter converter = new NRefactoryToRubyConverter(SupportedLanguage.CSharp);
50
converter.IndentString = " ";
51
string Ruby = converter.Convert(csharp);
53
Assert.AreEqual(expectedRuby, Ruby);