~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/Libraries/NRefactory/Test/Parser/TypeLevel/CustomEventTests.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.IO;
 
6
using NUnit.Framework;
 
7
using ICSharpCode.NRefactory.Parser;
 
8
using ICSharpCode.NRefactory.Ast;
 
9
 
 
10
namespace ICSharpCode.NRefactory.Tests.Ast
 
11
{
 
12
        [TestFixture]
 
13
        public class CustomEventTests
 
14
        {
 
15
                #region C#
 
16
                        // No C# representation
 
17
                #endregion
 
18
                
 
19
                #region VB.NET
 
20
                [Test]
 
21
                public void VBNetCustomEventsStatementTest()
 
22
                {
 
23
                        string code = @" Public Custom Event TestEvent As EventHandler
 
24
        AddHandler(ByVal value As EventHandler)
 
25
            Handlers = CType([Delegate].Combine(Handlers, value), _
 
26
                EventHandler)
 
27
        End AddHandler
 
28
 
 
29
        RemoveHandler(ByVal value as EventHandler)
 
30
            Handlers = CType([Delegate].Remove(Handlers, value), _
 
31
                EventHandler)
 
32
        End RemoveHandler
 
33
 
 
34
        RaiseEvent(ByVal sender As Object, ByVal e As EventArgs)
 
35
            Dim TempHandlers As EventHandler = Handlers
 
36
 
 
37
            If TempHandlers IsNot Nothing Then
 
38
                TempHandlers(sender, e)
 
39
            End If
 
40
        End RaiseEvent
 
41
    End Event";
 
42
                        EventDeclaration customEventDecl = ParseUtilVBNet.ParseTypeMember<EventDeclaration>(code);
 
43
                        Assert.IsNotNull(customEventDecl);
 
44
                        Assert.AreEqual("TestEvent", customEventDecl.Name);
 
45
                }
 
46
                #endregion
 
47
        }
 
48
}