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 System.ComponentModel;
6
using System.ComponentModel.Design;
7
using System.ComponentModel.Design.Serialization;
9
using System.Windows.Forms;
11
using ICSharpCode.RubyBinding;
12
using ICSharpCode.Scripting.Tests.Utils;
13
using NUnit.Framework;
14
using RubyBinding.Tests.Utils;
16
namespace RubyBinding.Tests.Designer
19
public class GenerateToolTipFormTestFixture
21
string generatedRubyCode;
24
public void SetUpFixture()
26
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
27
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
28
IEventBindingService eventBindingService = new MockEventBindingService(host);
29
Form form = (Form)host.RootComponent;
30
form.ClientSize = new Size(284, 264);
32
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
33
PropertyDescriptor descriptor = descriptors.Find("Name", false);
34
descriptor.SetValue(form, "MainForm");
36
ToolTip toolTip = (ToolTip)host.CreateComponent(typeof(ToolTip), "toolTip1");
37
toolTip.SetToolTip(form, "test");
39
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
40
using (serializationManager.CreateSession()) {
41
RubyCodeDomSerializer serializer = new RubyCodeDomSerializer(" ");
42
generatedRubyCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty, 1);
48
public void GeneratedCode()
50
string expectedCode = " @components = System::ComponentModel::Container.new()\r\n" +
51
" @toolTip1 = System::Windows::Forms::ToolTip.new(@components)\r\n" +
52
" self.SuspendLayout()\r\n" +
56
" self.ClientSize = System::Drawing::Size.new(284, 264)\r\n" +
57
" self.Name = \"MainForm\"\r\n" +
58
" @toolTip1.SetToolTip(self, \"test\")\r\n" +
59
" self.ResumeLayout(false)\r\n";
61
Assert.AreEqual(expectedCode, generatedRubyCode, generatedRubyCode);