// // // // // $Revision$ // using System; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.RubyBinding; using NUnit.Framework; using RubyBinding.Tests.Utils; namespace RubyBinding.Tests.Converter { /// /// Tests the ConvertCSharpToRubyMenuCommand. /// [TestFixture] public class ConvertCSharpToRubyMenuCommandTestFixture : ConvertToRubyMenuCommand { string newFileText; string defaultFileName; string language; string fileNamePassedToGetParseInformation; MockEditableViewContent mockViewContent; [TestFixtureSetUp] public void SetUpFixture() { mockViewContent = new MockEditableViewContent(); mockViewContent.Text = "class Foo\r\n" + "{\r\n" + " public Foo()\r\n" + " {\r\n" + " }\r\n" + "}"; mockViewContent.PrimaryFileName = new FileName("test.cs"); MockWorkbench workbench = new MockWorkbench(); MockWorkbenchWindow window = new MockWorkbenchWindow(); window.ActiveViewContent = mockViewContent; workbench.ActiveWorkbenchWindow = window; MockTextEditorOptions options = new MockTextEditorOptions(); options.IndentationSize = 4; options.ConvertTabsToSpaces = true; mockViewContent.TextEditorOptions = options; Run(workbench); } [Test] public void GeneratedRubyCode() { string code = "class Foo\r\n" + " def initialize()\r\n" + " end\r\n" + "end"; Assert.AreEqual(code, newFileText); } [Test] public void NewFileName() { Assert.AreEqual("Generated.rb", defaultFileName); } [Test] public void NewFileLanguage() { Assert.AreEqual("Ruby", language); } [Test] public void NameOfFileBeingConvertedIsPassedToParserServiceGetInformation() { Assert.AreEqual("test.cs", fileNamePassedToGetParseInformation); } protected override void NewFile(string defaultName, string language, string content) { defaultFileName = defaultName; this.language = language; newFileText = content; } protected override ParseInformation GetParseInformation(string fileName) { fileNamePassedToGetParseInformation = fileName; return new ParseInformation(new DefaultCompilationUnit(new DefaultProjectContent())); } } }