~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Converter/ConvertVBNetToRubyMenuCommandTestFixture.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.Core;
 
6
using ICSharpCode.RubyBinding;
 
7
using ICSharpCode.Scripting.Tests.Utils;
 
8
using ICSharpCode.SharpDevelop.Dom;
 
9
using NUnit.Framework;
 
10
using RubyBinding.Tests.Utils;
 
11
 
 
12
namespace RubyBinding.Tests.Converter
 
13
{
 
14
        [TestFixture]
 
15
        public class ConvertVBNetToRubyMenuCommandTestFixture : ConvertToRubyMenuCommand
 
16
        {
 
17
                string newFileText;
 
18
                string defaultFileName;
 
19
                string language;
 
20
                string fileNamePassedToGetParseInformation;
 
21
                
 
22
                [SetUp]
 
23
                public void Init()
 
24
                {
 
25
                        MockWorkbench workbench = MockWorkbench.CreateWorkbenchWithOneViewContent("test.vb");
 
26
                        workbench.ActiveMockEditableViewContent.Text = 
 
27
                                "class Foo\r\n" +
 
28
                                "    Public Sub New\r\n" +
 
29
                                "    End Sub\r\n" +
 
30
                                "end class";
 
31
                        
 
32
                        MockTextEditorOptions options = workbench.ActiveMockEditableViewContent.MockTextEditorOptions;  
 
33
                        options.ConvertTabsToSpaces = false;
 
34
                        options.IndentationSize = 2;
 
35
                        
 
36
                        Run(workbench);
 
37
                }
 
38
                
 
39
                [Test]
 
40
                public void GeneratedRubyCode()
 
41
                {
 
42
                        string expectedRubyCode = 
 
43
                                "class Foo\r\n" +
 
44
                                "\tdef initialize()\r\n" +
 
45
                                "\tend\r\n" +
 
46
                                "end";
 
47
                        
 
48
                        Assert.AreEqual(expectedRubyCode, newFileText);
 
49
                }
 
50
                
 
51
                [Test]
 
52
                public void NewFileName()
 
53
                {
 
54
                        Assert.AreEqual("Generated.rb", defaultFileName);
 
55
                }
 
56
 
 
57
                [Test]
 
58
                public void NewFileLanguage()
 
59
                {
 
60
                        Assert.AreEqual("Ruby", language);
 
61
                }
 
62
                
 
63
                [Test]
 
64
                public void NameOfFileBeingConvertedIsPassedToParserServiceGetInformation()
 
65
                {
 
66
                        Assert.AreEqual("test.vb", fileNamePassedToGetParseInformation);
 
67
                }
 
68
                
 
69
                protected override void NewFile(string defaultName, string language, string content)
 
70
                {
 
71
                        defaultFileName = defaultName;
 
72
                        this.language = language;
 
73
                        newFileText = content;
 
74
                }
 
75
                
 
76
                protected override ParseInformation GetParseInformation(string fileName)
 
77
                {
 
78
                        fileNamePassedToGetParseInformation = fileName;
 
79
                        return new ParseInformation(new DefaultCompilationUnit(new DefaultProjectContent()));
 
80
                }
 
81
        }
 
82
}