~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/PropertyDeclarationTests.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
Import upstream version 4.0.5+dfsg

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.IO;
 
6
using ICSharpCode.NRefactory.VB.Ast;
 
7
using NUnit.Framework;
 
8
 
 
9
namespace ICSharpCode.NRefactory.VB.Tests.Ast
 
10
{
 
11
        [TestFixture]
 
12
        public class PropertyDeclarationTests
 
13
        {
 
14
                #region VB.NET
 
15
                [Test]
 
16
                public void VBNetSimpleGetSetPropertyDeclarationTest()
 
17
                {
 
18
                        PropertyDeclaration pd = ParseUtil.ParseTypeMember<PropertyDeclaration>("Property MyProperty As Integer \n Get \n End Get \n Set \n End Set\nEnd Property");
 
19
                        Assert.AreEqual("MyProperty", pd.Name);
 
20
                        Assert.IsTrue(pd.HasGetRegion);
 
21
                        Assert.IsTrue(pd.HasSetRegion);
 
22
                }
 
23
                
 
24
                [Test]
 
25
                public void VBNetSimpleGetPropertyDeclarationTest()
 
26
                {
 
27
                        PropertyDeclaration pd = ParseUtil.ParseTypeMember<PropertyDeclaration>("ReadOnly Property MyProperty \nGet\nEnd Get\nEnd Property");
 
28
                        Assert.AreEqual("MyProperty", pd.Name);
 
29
                        Assert.IsTrue(pd.HasGetRegion);
 
30
                        Assert.IsFalse(pd.HasSetRegion);
 
31
                        Assert.IsTrue((pd.Modifier & Modifiers.ReadOnly) == Modifiers.ReadOnly);
 
32
                }
 
33
                
 
34
                [Test]
 
35
                public void VBNetSimpleSetPropertyDeclarationTest()
 
36
                {
 
37
                        PropertyDeclaration pd = ParseUtil.ParseTypeMember<PropertyDeclaration>("WriteOnly Property MyProperty \n Set\nEnd Set\nEnd Property ");
 
38
                        Assert.AreEqual("MyProperty", pd.Name);
 
39
                        Assert.IsFalse(pd.HasGetRegion);
 
40
                        Assert.IsTrue(pd.HasSetRegion);
 
41
                        Assert.IsTrue((pd.Modifier & Modifiers.WriteOnly) == Modifiers.WriteOnly);
 
42
                }
 
43
                
 
44
                [Test]
 
45
                public void VBNetAutoPropertyTest()
 
46
                {
 
47
                        PropertyDeclaration pd = ParseUtil.ParseTypeMember<PropertyDeclaration>("Property MyProperty");
 
48
                        Assert.AreEqual("MyProperty", pd.Name);
 
49
                        Assert.IsTrue(pd.HasGetRegion);
 
50
                        Assert.IsTrue(pd.HasSetRegion);
 
51
                        Assert.AreEqual(pd.Initializer, Expression.Null);
 
52
                }
 
53
                
 
54
                [Test]
 
55
                public void VBNetReadOnlyAutoPropertyTest()
 
56
                {
 
57
                        PropertyDeclaration pd = ParseUtil.ParseTypeMember<PropertyDeclaration>("ReadOnly Property MyProperty");
 
58
                        Assert.AreEqual("MyProperty", pd.Name);
 
59
                        Assert.IsTrue(pd.HasGetRegion);
 
60
                        Assert.IsFalse(pd.HasSetRegion);
 
61
                        Assert.AreEqual(pd.Initializer, Expression.Null);
 
62
                }
 
63
                
 
64
                [Test]
 
65
                public void VBNetWriteOnlyAutoPropertyTest()
 
66
                {
 
67
                        PropertyDeclaration pd = ParseUtil.ParseTypeMember<PropertyDeclaration>("WriteOnly Property MyProperty");
 
68
                        Assert.AreEqual("MyProperty", pd.Name);
 
69
                        Assert.IsFalse(pd.HasGetRegion);
 
70
                        Assert.IsTrue(pd.HasSetRegion);
 
71
                        Assert.AreEqual(pd.Initializer, Expression.Null);
 
72
                }
 
73
                
 
74
                [Test]
 
75
                public void VBNetSimpleInitializerAutoPropertyTest()
 
76
                {
 
77
                        PropertyDeclaration pd = ParseUtil.ParseTypeMember<PropertyDeclaration>("Property MyProperty = 5");
 
78
                        Assert.AreEqual("MyProperty", pd.Name);
 
79
                        Assert.IsTrue(pd.HasGetRegion);
 
80
                        Assert.IsTrue(pd.HasSetRegion);
 
81
                        Assert.AreEqual(pd.Initializer.ToString(), new PrimitiveExpression(5).ToString());
 
82
                }
 
83
                
 
84
                [Test]
 
85
                public void VBNetSimpleInitializerAutoPropertyWithTypeTest()
 
86
                {
 
87
                        PropertyDeclaration pd = ParseUtil.ParseTypeMember<PropertyDeclaration>("Property MyProperty As Integer = 5");
 
88
                        Assert.AreEqual("MyProperty", pd.Name);
 
89
                        Assert.AreEqual("System.Int32", pd.TypeReference.Type);
 
90
                        Assert.IsTrue(pd.HasGetRegion);
 
91
                        Assert.IsTrue(pd.HasSetRegion);
 
92
                        Assert.AreEqual(pd.Initializer.ToString(), new PrimitiveExpression(5).ToString());
 
93
                }
 
94
                
 
95
                [Test]
 
96
                public void VBNetSimpleObjectInitializerAutoPropertyTest()
 
97
                {
 
98
                        PropertyDeclaration pd = ParseUtil.ParseTypeMember<PropertyDeclaration>("Property MyProperty As New List");
 
99
                        Assert.AreEqual("MyProperty", pd.Name);
 
100
                        Assert.AreEqual("List", pd.TypeReference.Type);
 
101
                        Assert.IsTrue(pd.HasGetRegion);
 
102
                        Assert.IsTrue(pd.HasSetRegion);
 
103
                        Assert.AreEqual(pd.Initializer.ToString(), new ObjectCreateExpression(new TypeReference("List"), null).ToString());
 
104
                }
 
105
                #endregion
 
106
        }
 
107
}