/NRefactory/ICSharpCode.NRefactory.VB.Tests/Parser/TypeLevel/ConstructorDeclarationTests.cs

http://github.com/icsharpcode/ILSpy · C# · 34 lines · 29 code · 3 blank · 2 comment · 0 complexity · 310ace168b13347fc35fe4369447045e MD5 · raw file

  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. using System;
  4. using ICSharpCode.NRefactory.VB.Ast;
  5. using NUnit.Framework;
  6. namespace ICSharpCode.NRefactory.VB.Tests.Ast
  7. {
  8. [TestFixture]
  9. public class ConstructorDeclarationTests
  10. {
  11. #region VB.NET
  12. [Test]
  13. public void VBNetConstructorDeclarationTest1()
  14. {
  15. string program = @"Sub New()
  16. End Sub";
  17. ConstructorDeclaration cd = ParseUtil.ParseTypeMember<ConstructorDeclaration>(program);
  18. Assert.IsTrue(cd.ConstructorInitializer.IsNull);
  19. }
  20. [Test]
  21. public void VBNetConstructorDeclarationTest2()
  22. {
  23. ConstructorDeclaration cd = ParseUtil.ParseTypeMember<ConstructorDeclaration>("Sub New(x As Integer, Optional y As String) \nEnd Sub");
  24. Assert.AreEqual(2, cd.Parameters.Count);
  25. Assert.AreEqual("System.Int32", cd.Parameters[0].TypeReference.Type);
  26. Assert.AreEqual("System.String", cd.Parameters[1].TypeReference.Type);
  27. Assert.AreEqual(ParameterModifiers.Optional, cd.Parameters[1].ParamModifier & ParameterModifiers.Optional);
  28. }
  29. #endregion
  30. }
  31. }