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 GenerateFormLocationTestFixture
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("Location", false);
34
descriptor.SetValue(form, new Point(10, 20));
36
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
37
namePropertyDescriptor.SetValue(form, "MainForm");
39
DesignerSerializationManager serializationManager = new DesignerSerializationManager(host);
40
using (serializationManager.CreateSession()) {
41
RubyCodeDomSerializer serializer = new RubyCodeDomSerializer(" ");
42
generatedRubyCode = serializer.GenerateInitializeComponentMethodBody(host, serializationManager, 1);
48
public void GeneratedCode()
50
string expectedCode = " self.SuspendLayout()\r\n" +
54
" self.ClientSize = System::Drawing::Size.new(284, 264)\r\n" +
55
" self.Location = System::Drawing::Point.new(10, 20)\r\n" +
56
" self.Name = \"MainForm\"\r\n" +
57
" self.ResumeLayout(false)\r\n";
59
Assert.AreEqual(expectedCode, generatedRubyCode);