|
' Licensed to the .NET Foundation under one or more agreements.
' The .NET Foundation licenses this file to you under the MIT license.
' See the LICENSE file in the project root for more information.
Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Test.Utilities
Imports Roslyn.Test.Utilities
Namespace Microsoft.VisualStudio.LanguageServices.UnitTests.CodeModel.VisualBasic
Public Class CodeImportTests
Inherits AbstractCodeImportTests
#Region "GetStartPoint() tests"
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub TestGetStartPoint1()
Dim code =
<Code>
Imports $$System
</Code>
TestGetStartPoint(code,
Part(EnvDTE.vsCMPart.vsCMPartAttributes,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartAttributesWithDelimiter,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartBody,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=14)),
Part(EnvDTE.vsCMPart.vsCMPartBodyWithDelimiter,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=14)),
Part(EnvDTE.vsCMPart.vsCMPartHeader,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=14)),
Part(EnvDTE.vsCMPart.vsCMPartHeaderWithAttributes,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=14)),
Part(EnvDTE.vsCMPart.vsCMPartName,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartNavigate,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=14)),
Part(EnvDTE.vsCMPart.vsCMPartWhole,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=14)),
Part(EnvDTE.vsCMPart.vsCMPartWholeWithAttributes,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=14)))
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub TestGetStartPoint2()
Dim code =
<Code>
Imports System, $$System.Linq
</Code>
TestGetStartPoint(code,
Part(EnvDTE.vsCMPart.vsCMPartAttributes,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartAttributesWithDelimiter,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartBody,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=27)),
Part(EnvDTE.vsCMPart.vsCMPartBodyWithDelimiter,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=27)),
Part(EnvDTE.vsCMPart.vsCMPartHeader,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=27)),
Part(EnvDTE.vsCMPart.vsCMPartHeaderWithAttributes,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=27)),
Part(EnvDTE.vsCMPart.vsCMPartName,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartNavigate,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=27)),
Part(EnvDTE.vsCMPart.vsCMPartWhole,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=27)),
Part(EnvDTE.vsCMPart.vsCMPartWholeWithAttributes,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=27)))
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub TestGetStartPoint3()
Dim code =
<Code>
Imports System, $$S = System.Linq
</Code>
TestGetStartPoint(code,
Part(EnvDTE.vsCMPart.vsCMPartAttributes,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartAttributesWithDelimiter,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartBody,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=31)),
Part(EnvDTE.vsCMPart.vsCMPartBodyWithDelimiter,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=31)),
Part(EnvDTE.vsCMPart.vsCMPartHeader,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=31)),
Part(EnvDTE.vsCMPart.vsCMPartHeaderWithAttributes,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=31)),
Part(EnvDTE.vsCMPart.vsCMPartName,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartNavigate,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=31)),
Part(EnvDTE.vsCMPart.vsCMPartWhole,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=31)),
Part(EnvDTE.vsCMPart.vsCMPartWholeWithAttributes,
TextPoint(line:=1, lineOffset:=1, absoluteOffset:=1, lineLength:=31)))
End Sub
#End Region
#Region "GetEndPoint() tests"
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub TestGetEndPoint1()
Dim code =
<Code>
Imports $$System
</Code>
TestGetEndPoint(code,
Part(EnvDTE.vsCMPart.vsCMPartAttributes,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartAttributesWithDelimiter,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartBody,
TextPoint(line:=1, lineOffset:=15, absoluteOffset:=15, lineLength:=14)),
Part(EnvDTE.vsCMPart.vsCMPartBodyWithDelimiter,
TextPoint(line:=1, lineOffset:=15, absoluteOffset:=15, lineLength:=14)),
Part(EnvDTE.vsCMPart.vsCMPartHeader,
TextPoint(line:=1, lineOffset:=15, absoluteOffset:=15, lineLength:=14)),
Part(EnvDTE.vsCMPart.vsCMPartHeaderWithAttributes,
TextPoint(line:=1, lineOffset:=15, absoluteOffset:=15, lineLength:=14)),
Part(EnvDTE.vsCMPart.vsCMPartName,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartNavigate,
TextPoint(line:=1, lineOffset:=15, absoluteOffset:=15, lineLength:=14)),
Part(EnvDTE.vsCMPart.vsCMPartWhole,
TextPoint(line:=1, lineOffset:=15, absoluteOffset:=15, lineLength:=14)),
Part(EnvDTE.vsCMPart.vsCMPartWholeWithAttributes,
TextPoint(line:=1, lineOffset:=15, absoluteOffset:=15, lineLength:=14)))
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub TestGetEndPoint2()
Dim code =
<Code>
Imports System, $$System.Linq
</Code>
TestGetEndPoint(code,
Part(EnvDTE.vsCMPart.vsCMPartAttributes,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartAttributesWithDelimiter,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartBody,
TextPoint(line:=1, lineOffset:=28, absoluteOffset:=28, lineLength:=27)),
Part(EnvDTE.vsCMPart.vsCMPartBodyWithDelimiter,
TextPoint(line:=1, lineOffset:=28, absoluteOffset:=28, lineLength:=27)),
Part(EnvDTE.vsCMPart.vsCMPartHeader,
TextPoint(line:=1, lineOffset:=28, absoluteOffset:=28, lineLength:=27)),
Part(EnvDTE.vsCMPart.vsCMPartHeaderWithAttributes,
TextPoint(line:=1, lineOffset:=28, absoluteOffset:=28, lineLength:=27)),
Part(EnvDTE.vsCMPart.vsCMPartName,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartNavigate,
TextPoint(line:=1, lineOffset:=28, absoluteOffset:=28, lineLength:=27)),
Part(EnvDTE.vsCMPart.vsCMPartWhole,
TextPoint(line:=1, lineOffset:=28, absoluteOffset:=28, lineLength:=27)),
Part(EnvDTE.vsCMPart.vsCMPartWholeWithAttributes,
TextPoint(line:=1, lineOffset:=28, absoluteOffset:=28, lineLength:=27)))
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub TestGetEndPoint3()
Dim code =
<Code>
Imports System, $$S = System.Linq
</Code>
TestGetEndPoint(code,
Part(EnvDTE.vsCMPart.vsCMPartAttributes,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartAttributesWithDelimiter,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartBody,
TextPoint(line:=1, lineOffset:=32, absoluteOffset:=32, lineLength:=31)),
Part(EnvDTE.vsCMPart.vsCMPartBodyWithDelimiter,
TextPoint(line:=1, lineOffset:=32, absoluteOffset:=32, lineLength:=31)),
Part(EnvDTE.vsCMPart.vsCMPartHeader,
TextPoint(line:=1, lineOffset:=32, absoluteOffset:=32, lineLength:=31)),
Part(EnvDTE.vsCMPart.vsCMPartHeaderWithAttributes,
TextPoint(line:=1, lineOffset:=32, absoluteOffset:=32, lineLength:=31)),
Part(EnvDTE.vsCMPart.vsCMPartName,
NullTextPoint),
Part(EnvDTE.vsCMPart.vsCMPartNavigate,
TextPoint(line:=1, lineOffset:=32, absoluteOffset:=32, lineLength:=31)),
Part(EnvDTE.vsCMPart.vsCMPartWhole,
TextPoint(line:=1, lineOffset:=32, absoluteOffset:=32, lineLength:=31)),
Part(EnvDTE.vsCMPart.vsCMPartWholeWithAttributes,
TextPoint(line:=1, lineOffset:=32, absoluteOffset:=32, lineLength:=31)))
End Sub
#End Region
#Region "FullName tests"
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub TestFullName1()
Dim code =
<Code>
Imports $$System
</Code>
Assert.Throws(Of NotImplementedException)(
Sub()
TestFullName(code, "System")
End Sub)
End Sub
#End Region
#Region "Name tests"
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub TestName1()
Dim code =
<Code>
Imports $$Goo
</Code>
TestName(code, "Goo")
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub TestName2()
Dim code =
<Code>
Imports System$$, System.Linq
</Code>
TestName(code, "System")
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub TestName3()
Dim code =
<Code>
Imports System, System.Linq$$
</Code>
TestName(code, "System.Linq")
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub TestName4()
Dim code =
<Code>
Imports System _
.
Linq$$
</Code>
TestName(code, "System.Linq")
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub TestName5()
Dim code =
<Code>
Imports System, S = System.Linq$$
</Code>
TestName(code, "System.Linq")
End Sub
#End Region
#Region "Namespace tests"
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub TestNamespace1()
Dim code =
<Code>
Imports $$Goo
</Code>
TestNamespace(code, "Goo")
End Sub
<WpfFact, Trait(Traits.Feature, Traits.Features.CodeModel)>
Public Sub TestNamespace2()
Dim code =
<Code>
Imports System _
.
Linq$$
</Code>
TestNamespace(code, "System.Linq")
End Sub
#End Region
Protected Overrides ReadOnly Property LanguageName As String
Get
Return LanguageNames.VisualBasic
End Get
End Property
End Class
End Namespace
|