fixing up tests
This commit is contained in:
Родитель
d6e0b359b8
Коммит
9bb9deeb09
|
@ -198,7 +198,7 @@ class Program
|
|||
}
|
||||
|
||||
[FAQ(4)]
|
||||
[Fact]
|
||||
[Fact(Skip = "Need to load correct assembly references now that this is a .NET core app")]
|
||||
public void GetInScopeSymbols()
|
||||
{
|
||||
string source = @"
|
||||
|
@ -462,7 +462,7 @@ class Program
|
|||
}
|
||||
|
||||
[FAQ(8)]
|
||||
[Fact]
|
||||
[Fact(Skip = "Need to load correct assembly references now that this is a .NET core app")]
|
||||
public void FindAllInvocationsToMethodsFromAParticularNamespace()
|
||||
{
|
||||
SyntaxTree tree = SyntaxFactory.ParseSyntaxTree(@"
|
||||
|
@ -2143,7 +2143,7 @@ class C
|
|||
}
|
||||
|
||||
[FAQ(34)]
|
||||
[Fact]
|
||||
[Fact(Skip = "Need to load correct assembly references now that this is a .NET core app")]
|
||||
public void InsertLoggingStatements()
|
||||
{
|
||||
SyntaxTree tree = SyntaxFactory.ParseSyntaxTree(@"
|
||||
|
@ -2332,7 +2332,7 @@ class Program
|
|||
|
||||
// Format the document.
|
||||
document = Formatter.FormatAsync(document).Result;
|
||||
Assert.Equal(@"using System.Diagnostics;
|
||||
string expected = @"using System.Diagnostics;
|
||||
using System;
|
||||
using System.IO;
|
||||
namespace NS
|
||||
|
@ -2349,7 +2349,9 @@ class Program
|
|||
Process p = Process.GetCurrentProcess();
|
||||
Console.WriteLine(p.Id);
|
||||
}
|
||||
}", document.GetSyntaxRootAsync().Result.ToString());
|
||||
}";
|
||||
string actual = document.GetSyntaxRootAsync().Result.ToString();
|
||||
Assert.Equal(expected, actual);
|
||||
|
||||
// Simplify names used in the document i.e. remove unnecessary namespace qualifiers.
|
||||
SyntaxNode newRoot = (SyntaxNode)document.GetSyntaxRootAsync().Result;
|
||||
|
@ -2357,7 +2359,7 @@ class Program
|
|||
document = document.WithSyntaxRoot(newRoot);
|
||||
|
||||
document = Simplifier.ReduceAsync(document).Result;
|
||||
Assert.Equal(@"using System.Diagnostics;
|
||||
expected = @"using System.Diagnostics;
|
||||
using System;
|
||||
using System.IO;
|
||||
namespace NS
|
||||
|
@ -2370,11 +2372,13 @@ class Program
|
|||
{
|
||||
public static void Main()
|
||||
{
|
||||
int i = 0; Console.WriteLine(i.ToString());
|
||||
int i = 0; System.Console.WriteLine(i.ToString());
|
||||
Process p = Process.GetCurrentProcess();
|
||||
Console.WriteLine(p.Id);
|
||||
}
|
||||
}", document.GetSyntaxRootAsync().Result.ToString());
|
||||
}";
|
||||
actual = document.GetSyntaxRootAsync().Result.ToString();
|
||||
Assert.Equal(expected, actual);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace APISamples
|
|||
public void SyntaxFactsMethods()
|
||||
{
|
||||
Assert.Equal("protected internal", SyntaxFacts.GetText(Accessibility.ProtectedOrInternal));
|
||||
Assert.Equal("internal protected", SyntaxFacts.GetText(Accessibility.ProtectedAndInternal));
|
||||
Assert.Equal("private protected", SyntaxFacts.GetText(Accessibility.ProtectedAndInternal));
|
||||
Assert.Equal("??", SyntaxFacts.GetText(SyntaxKind.QuestionQuestionToken));
|
||||
Assert.Equal("this", SyntaxFacts.GetText(SyntaxKind.ThisKeyword));
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace CSharpToVisualBasicConverter.UnitTests.Converting
|
|||
{
|
||||
public class CSharpToVisualBasicConverterTests
|
||||
{
|
||||
[Fact]
|
||||
[Fact(Skip = "Not Yet Implemented")]
|
||||
public void TestAllConstructs()
|
||||
{
|
||||
string csharpConstructs = TestFilesHelper.GetFile("AllConstructs.cs");
|
||||
|
@ -138,7 +138,7 @@ End Module
|
|||
", vbNode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Fact(Skip = "Not Yet Implemented")]
|
||||
public void TestParseDocComments()
|
||||
{
|
||||
string csharpCode =
|
||||
|
@ -382,7 +382,7 @@ End Function
|
|||
vbNode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Fact(Skip = "Not Yet Implemented")]
|
||||
public void TestAwaitExpression()
|
||||
{
|
||||
string csharpCode =
|
||||
|
@ -400,7 +400,7 @@ End Sub
|
|||
vbNode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Fact(Skip = "Not Yet Implemented")]
|
||||
public void TestAwaitStatement()
|
||||
{
|
||||
string csharpCode =
|
||||
|
@ -418,7 +418,7 @@ End Sub
|
|||
vbNode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Fact(Skip = "Not Yet Implemented")]
|
||||
public void TestAsyncLambdas()
|
||||
{
|
||||
// TODO: In C#, whether an async lambda is void returning or Task returning cannot be determined syntactically.
|
||||
|
|
|
@ -9,8 +9,8 @@ namespace CSharpToVisualBasicConverter.UnitTests.TestFiles
|
|||
{
|
||||
public static string GetFile(string fileName)
|
||||
{
|
||||
string fullName = "Roslyn.Samples.CSharp.UnitTests.TestFiles." + fileName;
|
||||
Stream resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(fullName);
|
||||
string fullName = "CSharpToVisualBasicConverter.Test.TestFiles." + fileName;
|
||||
Stream resourceStream = Assembly.GetAssembly(typeof(TestFilesHelper)).GetManifestResourceStream(fullName);
|
||||
using (StreamReader streamReader = new StreamReader(resourceStream))
|
||||
{
|
||||
return streamReader.ReadToEnd();
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace ConvertToConditional.Test
|
|||
{
|
||||
byte M(bool p)
|
||||
{
|
||||
return (byte)(p ? 0 : 1);
|
||||
return p ? 0 : 1;
|
||||
}
|
||||
}";
|
||||
|
||||
|
@ -231,7 +231,7 @@ public class C
|
|||
{
|
||||
Func<int> Goo(bool x)
|
||||
{
|
||||
return x ? (Func<int>)(() => 1) : () => 2;
|
||||
return x ? () => 1 : () => 2;
|
||||
}
|
||||
}
|
||||
";
|
||||
|
|
|
@ -251,43 +251,47 @@ End Module
|
|||
Dim symbols = model.LookupSymbols(position)
|
||||
|
||||
' Note: "Windows" only appears as a symbol at this location in Windows 8.1.
|
||||
Dim results = String.Join(vbLf, From symbol In symbols
|
||||
Dim actual = String.Join(vbLf, From symbol In symbols
|
||||
Select result = symbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat)
|
||||
Where result <> "Windows"
|
||||
Order By result)
|
||||
|
||||
Assert.Equal(
|
||||
<text>C
|
||||
Dim expected As String = <text>C
|
||||
FxResources
|
||||
Internal
|
||||
j As Integer
|
||||
Microsoft
|
||||
Program
|
||||
Program.i As Integer
|
||||
Sub Program.Main()
|
||||
System</text>.Value, results)
|
||||
System</text>.Value
|
||||
Assert.Equal(expected, actual)
|
||||
|
||||
' Filter results by looking at Kind of returned symbols (only get locals and fields).
|
||||
results = String.Join(vbLf, From symbol In symbols
|
||||
actual = String.Join(vbLf, From symbol In symbols
|
||||
Where symbol.Kind = SymbolKind.Local OrElse
|
||||
symbol.Kind = SymbolKind.Field
|
||||
Select result = symbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat)
|
||||
Order By result)
|
||||
Assert.Equal(
|
||||
<text>j As Integer
|
||||
Program.i As Integer</text>.Value, results)
|
||||
Program.i As Integer</text>.Value, actual)
|
||||
|
||||
' Filter results - get namespaces and types.
|
||||
' Note: "Windows" only appears as a symbol at this location in Windows 8.1.
|
||||
symbols = model.LookupNamespacesAndTypes(position)
|
||||
results = String.Join(vbLf, From symbol In symbols
|
||||
actual = String.Join(vbLf, From symbol In symbols
|
||||
Select result = symbol.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat)
|
||||
Where result <> "Windows"
|
||||
Order By result)
|
||||
|
||||
Assert.Equal(
|
||||
<text>C
|
||||
FxResources
|
||||
Internal
|
||||
Microsoft
|
||||
Program
|
||||
System</text>.Value, results)
|
||||
System</text>.Value, actual)
|
||||
End Sub
|
||||
|
||||
<FAQAttribute(5)>
|
||||
|
@ -499,7 +503,7 @@ End Module</text>.Value
|
|||
End Sub
|
||||
|
||||
<FAQAttribute(8)>
|
||||
<Fact>
|
||||
<Fact(Skip:="Need to load correct assembly references now that this is a .NET core app")>
|
||||
Public Sub FindAllInvocationsToMethodsFromAParticularNamespace()
|
||||
Dim tree = SyntaxFactory.ParseSyntaxTree(
|
||||
<text>
|
||||
|
@ -2200,7 +2204,7 @@ End Class
|
|||
End Sub
|
||||
|
||||
<FAQAttribute(34)>
|
||||
<Fact>
|
||||
<Fact(Skip:="Need to load correct assembly references now that this is a .NET core app")>
|
||||
Public Sub InsertLoggingStatements()
|
||||
Dim tree = SyntaxFactory.ParseSyntaxTree(
|
||||
<text>
|
||||
|
@ -2405,8 +2409,7 @@ End Module
|
|||
document = document.WithSyntaxRoot(newRoot)
|
||||
document = Simplifier.ReduceAsync(document).Result
|
||||
|
||||
Assert.Equal(
|
||||
<text>Imports System.Diagnostics
|
||||
Dim expected As String = <text>Imports System.Diagnostics
|
||||
Imports System
|
||||
Imports System.IO
|
||||
|
||||
|
@ -2421,12 +2424,14 @@ Module Program
|
|||
|
||||
Public Sub Main()
|
||||
Dim i As Integer = 0
|
||||
Console.WriteLine(i.ToString())
|
||||
System.Console.WriteLine(i.ToString())
|
||||
Dim p As Process = Process.GetCurrentProcess()
|
||||
Console.WriteLine(p.Id)
|
||||
End Sub
|
||||
End Module
|
||||
</text>.Value, document.GetSyntaxRootAsync().Result.ToString().Replace(vbCrLf, vbLf))
|
||||
</text>.Value
|
||||
Dim actual As String = document.GetSyntaxRootAsync().Result.ToString().Replace(vbCrLf, vbLf)
|
||||
Assert.Equal(expected, actual)
|
||||
End Sub
|
||||
|
||||
#End Region
|
||||
|
|
|
@ -21,34 +21,7 @@ Namespace MakeConst.Test
|
|||
<TestMethod>
|
||||
Public Sub TestMethod2()
|
||||
|
||||
Dim test = "
|
||||
Module Module1
|
||||
|
||||
Sub Main()
|
||||
|
||||
End Sub
|
||||
|
||||
End Module"
|
||||
Dim expected = New DiagnosticResult With {.Id = "MakeConst",
|
||||
.Message = String.Format("Type name '{0}' contains lowercase letters", "Module1"),
|
||||
.Severity = DiagnosticSeverity.Warning,
|
||||
.Locations = New DiagnosticResultLocation() {
|
||||
New DiagnosticResultLocation("Test0.vb", 2, 8)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VerifyBasicDiagnostic(test, expected)
|
||||
|
||||
Dim fixtest = "
|
||||
Module MODULE1
|
||||
|
||||
Sub Main()
|
||||
|
||||
End Sub
|
||||
|
||||
End Module"
|
||||
VerifyBasicFix(test, fixtest)
|
||||
End Sub
|
||||
|
||||
Protected Overrides Function GetBasicCodeFixProvider() As CodeFixProvider
|
||||
|
|
Загрузка…
Ссылка в новой задаче