~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/BackendBindings/Ruby/RubyBinding/Test/Designer/LoadInheritedProtectedPanelFormTestFixture.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.Drawing;
 
8
using System.IO;
 
9
using System.Windows.Forms;
 
10
 
 
11
using ICSharpCode.RubyBinding;
 
12
using IronRuby.Compiler.Ast;
 
13
using NUnit.Framework;
 
14
using RubyBinding.Tests.Utils;
 
15
 
 
16
namespace RubyBinding.Tests.Designer
 
17
{
 
18
        [TestFixture]
 
19
        public class LoadInheritedProtectedPanelFormTestFixture : LoadFormTestFixtureBase
 
20
        {               
 
21
                public override string RubyCode {
 
22
                        get {
 
23
                                base.ComponentCreator.AddType("RubyBinding.Tests.Designer.ProtectedPanelDerivedForm", typeof(ProtectedPanelDerivedForm));
 
24
                                
 
25
                                return
 
26
                                        "class MainForm < RubyBinding::Tests::Designer::ProtectedPanelDerivedForm\r\n" +
 
27
                                        "    def InitializeComponent()\r\n" +
 
28
                                        "        self.SuspendLayout()\r\n" +
 
29
                                        "        # \r\n" +
 
30
                                        "        # panel1\r\n" +
 
31
                                        "        # \r\n" +
 
32
                                        "        self.panel1.Location = System::Drawing::Point.new(10, 15)\r\n" +
 
33
                                        "        self.panel1.Size = System::Drawing::Size.new(108, 120)\r\n" +
 
34
                                        "        # \r\n" +
 
35
                                        "        # form1\r\n" +
 
36
                                        "        # \r\n" +
 
37
                                        "        self.Location = System::Drawing::Point.new(10, 20)\r\n" +
 
38
                                        "        self.Name = \"form1\"\r\n" +
 
39
                                        "        self.Controls.Add(@textBox1)\r\n" +
 
40
                                        "        self.ResumeLayout(False)\r\n" +
 
41
                                        "    end\r\n" +
 
42
                                        "end";
 
43
                        }
 
44
                }
 
45
                
 
46
                ProtectedPanelDerivedForm DerivedForm { 
 
47
                        get { return Form as ProtectedPanelDerivedForm; }
 
48
                }
 
49
                                
 
50
                [Test]
 
51
                public void PanelLocation()
 
52
                {
 
53
                        Assert.AreEqual(new Point(10, 15), DerivedForm.PanelLocation);
 
54
                }
 
55
 
 
56
                [Test]
 
57
                public void PanelSize()
 
58
                {
 
59
                        Assert.AreEqual(new Size(108, 120), DerivedForm.PanelSize);
 
60
                }
 
61
                
 
62
                [Test]
 
63
                public void GetProtectedPanelObject()
 
64
                {
 
65
                        Assert.AreEqual(DerivedForm.GetPanel(), RubyControlFieldExpression.GetInheritedObject("panel1", DerivedForm));
 
66
                }
 
67
                
 
68
                [Test]
 
69
                public void GetProtectedPanelObjectIncorrectCase()
 
70
                {
 
71
                        Assert.AreEqual(DerivedForm.GetPanel(), RubyControlFieldExpression.GetInheritedObject("PANEL1", DerivedForm));
 
72
                }
 
73
                
 
74
                [Test]
 
75
                public void GetInheritedObjectPassedNull()
 
76
                {
 
77
                        Assert.IsNull(RubyControlFieldExpression.GetInheritedObject("panel1", null));
 
78
                }
 
79
                
 
80
                [Test]
 
81
                public void GetInheritedPanelObjectFromFieldExpression()
 
82
                {
 
83
                        SimpleAssignmentExpression assignment = RubyParserHelper.GetSimpleAssignmentExpression("self.panel1.Name = \"abc\"");
 
84
                        RubyControlFieldExpression field = RubyControlFieldExpression.Create(assignment.Left as AttributeAccess);
 
85
                                
 
86
                        Assert.AreEqual(DerivedForm.GetPanel(), field.GetObject(ComponentCreator));
 
87
                }
 
88
        }
 
89
}