~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/LoadEventHandlerTestFixture.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 System.Collections.Generic;
 
6
using System.ComponentModel;
 
7
using System.ComponentModel.Design;
 
8
using System.Drawing;
 
9
using System.IO;
 
10
using System.Windows.Forms;
 
11
 
 
12
using ICSharpCode.RubyBinding;
 
13
using ICSharpCode.Scripting.Tests.Utils;
 
14
using NUnit.Framework;
 
15
using RubyBinding.Tests.Utils;
 
16
 
 
17
namespace RubyBinding.Tests.Designer
 
18
{
 
19
        [TestFixture]
 
20
        public class LoadEventHandlerTestFixture : LoadFormTestFixtureBase
 
21
        {               
 
22
                public override string RubyCode {
 
23
                        get {
 
24
                                return
 
25
                                        "class TestForm < System::Windows::Forms::Form\r\n" +
 
26
                                        "    def InitializeComponent()\r\n" +
 
27
                                        "        self.SuspendLayout()\r\n" +
 
28
                                        "        # \r\n" +
 
29
                                        "        # TestForm\r\n" +
 
30
                                        "        # \r\n" +
 
31
                                        "        self.Name = \"TestForm\"\r\n" +
 
32
                                        "        self.Load { |sender, e| self.TestFormLoad(sender, e) }\r\n" +
 
33
                                        "        self.ResumeLayout(false)\r\n" +
 
34
                                        "    end\r\n" +
 
35
                                        "end";
 
36
                        }
 
37
                }
 
38
                
 
39
                public override void BeforeSetUpFixture()
 
40
                {
 
41
                        base.ComponentCreator.SetEventPropertyDescriptor(new MockPropertyDescriptor("abc", "TestFormLoad", true));
 
42
                }               
 
43
                
 
44
                public EventDescriptor GetLoadEventDescriptor()
 
45
                {
 
46
                        return TypeDescriptor.GetEvents(Form).Find("Load", true);
 
47
                }
 
48
                
 
49
                public MockPropertyDescriptor GetLoadEventPropertyDescriptor()
 
50
                {
 
51
                        EventDescriptor loadEventDescriptor = GetLoadEventDescriptor();
 
52
                        return base.ComponentCreator.GetEventProperty(loadEventDescriptor) as MockPropertyDescriptor;                   
 
53
                }
 
54
                
 
55
                [Test]
 
56
                public void EventPropertyDescriptorValueSetToEventHandlerMethodName()
 
57
                {
 
58
                        Assert.AreEqual("TestFormLoad", GetLoadEventPropertyDescriptor().GetValue(Form) as String);
 
59
                }
 
60
                
 
61
                [Test]
 
62
                public void PropertyDescriptorSetValueComponentIsForm()
 
63
                {
 
64
                        Assert.AreEqual(Form, GetLoadEventPropertyDescriptor().GetSetValueComponent());
 
65
                }               
 
66
        }
 
67
}