Skip to content

Commit

Permalink
Merge pull request #972 from DustinCampbell/update-xunit
Browse files Browse the repository at this point in the history
Update to latest xUnit and fix up tests affected by analyzers
  • Loading branch information
DustinCampbell authored Oct 2, 2017
2 parents ea17f16 + 300c970 commit 90a580f
Show file tree
Hide file tree
Showing 17 changed files with 53 additions and 54 deletions.
1 change: 0 additions & 1 deletion NuGet.Config
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
<add key="cli-deps" value="https://dotnet.myget.org/F/cli-deps/api/v3/index.json" />
<add key="xunit" value="https://www.myget.org/F/xunit/api/v3/index.json" />
</packageSources>
</configuration>
4 changes: 2 additions & 2 deletions build/Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
<SystemCompositionVersion>1.0.31</SystemCompositionVersion>
<SystemThreadingTasksDataflowVersion>4.6.0</SystemThreadingTasksDataflowVersion>
<SystemValueTupleVersion>4.3.0</SystemValueTupleVersion>
<XunitRunnerVisualStudioVersion>2.3.0-beta4-build3722</XunitRunnerVisualStudioVersion>
<XunitVersion>2.3.0-beta4-build3722</XunitVersion>
<XunitRunnerVisualStudioVersion>2.3.0-rc1-build3809</XunitRunnerVisualStudioVersion>
<XunitVersion>2.3.0-rc1-build3809</XunitVersion>
</PropertyGroup>

</Project>
2 changes: 1 addition & 1 deletion tests/OmniSharp.DotNetTest.Tests/RunTestFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public async Task RunXunitTestWithSimilarName()
testFramework: "xunit",
shouldPass: true);

Assert.Equal(1, response.Results.Length);
Assert.Single(response.Results);
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions tests/OmniSharp.MSBuild.Tests/ProjectFileInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task HelloWorld_has_correct_property_values()

Assert.NotNull(projectFileInfo);
Assert.Equal(projectFilePath, projectFileInfo.FilePath);
Assert.Equal(1, projectFileInfo.TargetFrameworks.Length);
Assert.Single(projectFileInfo.TargetFrameworks);
Assert.Equal("netcoreapp1.0", projectFileInfo.TargetFrameworks[0]);
Assert.Equal("bin/Debug/netcoreapp1.0/", projectFileInfo.OutputPath.Replace('\\', '/'));
Assert.Equal(3, projectFileInfo.SourceFiles.Length); // Program.cs, AssemblyInfo.cs, AssemblyAttributes.cs
Expand All @@ -67,7 +67,7 @@ public async Task HelloWorldSlim_has_correct_property_values()

Assert.NotNull(projectFileInfo);
Assert.Equal(projectFilePath, projectFileInfo.FilePath);
Assert.Equal(1, projectFileInfo.TargetFrameworks.Length);
Assert.Single(projectFileInfo.TargetFrameworks);
Assert.Equal("netcoreapp1.0", projectFileInfo.TargetFrameworks[0]);
Assert.Equal("bin/Debug/netcoreapp1.0/", projectFileInfo.OutputPath.Replace('\\', '/'));
Assert.Equal(3, projectFileInfo.SourceFiles.Length); // Program.cs, AssemblyInfo.cs, AssemblyAttributes.cs
Expand Down
2 changes: 1 addition & 1 deletion tests/OmniSharp.MSBuild.Tests/SolutionParsingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public void SolutionFile_Parse_simple_solution_with_different_spacing()

Assert.Null(solution.VisualStudioVersion);

Assert.Equal(1, solution.Projects.Length);
Assert.Single(solution.Projects);

Assert.Equal("{ Project GUID}", solution.Projects[0].ProjectTypeGuid);
Assert.Equal("Project name", solution.Projects[0].ProjectName);
Expand Down
20 changes: 10 additions & 10 deletions tests/OmniSharp.Roslyn.CSharp.Tests/BufferManagerFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ public async Task UpdateBufferIgnoresVoidRequests()
using (var host = CreateOmniSharpHost(new TestFile("test.cs", "class C {}")))
{
Assert.Equal(2, host.Workspace.CurrentSolution.Projects.Count());
Assert.Equal(1, host.Workspace.CurrentSolution.Projects.ElementAt(0).Documents.Count());
Assert.Equal(1, host.Workspace.CurrentSolution.Projects.ElementAt(1).Documents.Count());
Assert.Single(host.Workspace.CurrentSolution.Projects.ElementAt(0).Documents);
Assert.Single(host.Workspace.CurrentSolution.Projects.ElementAt(1).Documents);

await host.Workspace.BufferManager.UpdateBufferAsync(new Request() { });
Assert.Equal(2, host.Workspace.CurrentSolution.Projects.Count());
Assert.Equal(1, host.Workspace.CurrentSolution.Projects.ElementAt(0).Documents.Count());
Assert.Equal(1, host.Workspace.CurrentSolution.Projects.ElementAt(1).Documents.Count());
Assert.Single(host.Workspace.CurrentSolution.Projects.ElementAt(0).Documents);
Assert.Single(host.Workspace.CurrentSolution.Projects.ElementAt(1).Documents);

await host.Workspace.BufferManager.UpdateBufferAsync(new Request() { FileName = "", Buffer = "enum E {}" });
Assert.Equal(2, host.Workspace.CurrentSolution.Projects.Count());
Assert.Equal(1, host.Workspace.CurrentSolution.Projects.ElementAt(0).Documents.Count());
Assert.Equal(1, host.Workspace.CurrentSolution.Projects.ElementAt(1).Documents.Count());
Assert.Single(host.Workspace.CurrentSolution.Projects.ElementAt(0).Documents);
Assert.Single(host.Workspace.CurrentSolution.Projects.ElementAt(1).Documents);
}
}

Expand All @@ -47,7 +47,7 @@ public async Task UpdateBufferIgnoresFilePathsThatDontMatchAProjectPath()

await workspace.BufferManager.UpdateBufferAsync(new Request() { FileName = Path.Combine("some", " path.cs"), Buffer = "enum E {}" });
var documents = workspace.GetDocuments(Path.Combine("some", "path.cs"));
Assert.Equal(0, documents.Count());
Assert.Empty(documents);
}

[Fact]
Expand Down Expand Up @@ -110,13 +110,13 @@ public async Task UpdateBufferFindsProjectBasedOnNearestPath()

await workspace.BufferManager.UpdateBufferAsync(new Request() { FileName = Path.Combine("src", "root", "bar.cs"), Buffer = "enum E {}" });
var documents = workspace.GetDocuments(Path.Combine("src", "root", "bar.cs"));
Assert.Equal(1, documents.Count());
Assert.Single(documents);
Assert.Equal(Path.Combine("src", "root", "foo.csproj"), documents.ElementAt(0).Project.FilePath);
Assert.Equal(2, documents.ElementAt(0).Project.Documents.Count());

await workspace.BufferManager.UpdateBufferAsync(new Request() { FileName = Path.Combine("src", "root", "foo", "bar", "nested", "paths", "dance.cs"), Buffer = "enum E {}" });
documents = workspace.GetDocuments(Path.Combine("src", "root", "foo", "bar", "nested", "paths", "dance.cs"));
Assert.Equal(1, documents.Count());
Assert.Single(documents);
Assert.Equal(Path.Combine("src", "root", "foo", "bar", "insane.csproj"), documents.ElementAt(0).Project.FilePath);
Assert.Equal(2, documents.ElementAt(0).Project.Documents.Count());
}
Expand Down Expand Up @@ -177,7 +177,7 @@ private static OmniSharpWorkspace GetWorkspaceWithProjects()
Assert.Equal(4, workspace.CurrentSolution.Projects.Count());
foreach (var project in workspace.CurrentSolution.Projects)
{
Assert.Equal(1, project.Documents.Count());
Assert.Single(project.Documents);
}

return workspace;
Expand Down
2 changes: 1 addition & 1 deletion tests/OmniSharp.Roslyn.CSharp.Tests/DiagnosticsFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public async Task CodeCheckSpecifiedFileOnly()
var requestHandler = GetRequestHandler(host);
var quickFixes = await requestHandler.Handle(new CodeCheckRequest() { FileName = "a.cs" });

Assert.Equal(1, quickFixes.QuickFixes.Count());
Assert.Single(quickFixes.QuickFixes);
Assert.Equal("a.cs", quickFixes.QuickFixes.First().FileName);
}
}
Expand Down
12 changes: 6 additions & 6 deletions tests/OmniSharp.Roslyn.CSharp.Tests/DiagnosticsV2Facts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public async Task CodeCheckSpecifiedFileOnly(string filename)

await emitter.Emitted;

Assert.Equal(1, messages.Count);
Assert.Single(messages);
var message = messages.First();
Assert.Equal(1, message.Results.Count());
Assert.Single(message.Results);
var result = message.Results.First();
Assert.Equal(1, result.QuickFixes.Count());
Assert.Single(result.QuickFixes);
Assert.Equal(filename, result.FileName);
}
}
Expand All @@ -67,16 +67,16 @@ public async Task CheckAllFiles(string filename1, string filename2)

await emitter.Emitted;

Assert.Equal(1, messages.Count);
Assert.Single(messages);
var message = messages.First();
Assert.Equal(2, message.Results.Count());

var a = message.Results.First(x => x.FileName == filename1);
Assert.Equal(1, a.QuickFixes.Count());
Assert.Single(a.QuickFixes);
Assert.Equal(filename1, a.FileName);

var b = message.Results.First(x => x.FileName == filename2);
Assert.Equal(1, b.QuickFixes.Count());
Assert.Single(b.QuickFixes);
Assert.Equal(filename2, b.FileName);
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/OmniSharp.Roslyn.CSharp.Tests/FindReferencesFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public FooConsumer()
}";

var usages = await FindUsagesAsync(code, excludeDefinition: true);
Assert.Equal(1, usages.QuickFixes.Count());
Assert.Single(usages.QuickFixes);
}

[Fact]
Expand Down Expand Up @@ -224,7 +224,7 @@ public Foo Clone() {
};

var usages = await FindUsagesAsync(testFiles, onlyThisFile: true);
Assert.Equal(1, usages.QuickFixes.Count());
Assert.Single(usages.QuickFixes);
Assert.Equal("a.cs", usages.QuickFixes.ElementAt(0).FileName);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/OmniSharp.Roslyn.CSharp.Tests/GoToFileFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async Task ReturnsEmptyResponseForEmptyWorskpace()
{
var files = await GetFilesAsync();

Assert.Equal(0, files.Length);
Assert.Empty(files);
}

private async Task<QuickFix[]> GetFilesAsync(params TestFile[] testFiles)
Expand Down
2 changes: 1 addition & 1 deletion tests/OmniSharp.Roslyn.CSharp.Tests/GoToRegionFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public async Task DoesNotFindRegionsInFileWithoutRegions()
const string source = @"public class Fo$$o{}";

var regions = await GetRegionsAsync(source);
Assert.Equal(0, regions.Length);
Assert.Empty(regions);
}

private async Task<QuickFix[]> GetRegionsAsync(string source)
Expand Down
8 changes: 4 additions & 4 deletions tests/OmniSharp.Roslyn.CSharp.Tests/RenameFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public class Bar {
var changes = result.Changes.ToArray();

Assert.Equal(2, changes.Length);
Assert.Equal(1, changes[0].Changes.Count());
Assert.Single(changes[0].Changes);

Assert.Null(changes[0].Buffer);
Assert.Equal("xxx", changes[0].Changes.First().NewText);
Expand Down Expand Up @@ -200,7 +200,7 @@ public async Task Rename_DoesTheRightThingWhenDocumentIsNotFound()

var changes = result.Changes.ToArray();

Assert.Equal(1, changes.Length);
Assert.Single(changes);
Assert.Equal(testFile.FileName, changes[0].FileName);
}
}
Expand All @@ -221,7 +221,7 @@ public static void Main()
var testFile = new TestFile("test.cs", fileContent);
var result = await PerformRename(testFile, "foo");

Assert.Equal(0, result.Changes.Count());
Assert.Empty(result.Changes);
Assert.NotNull(result.ErrorMessage);
}

Expand All @@ -243,7 +243,7 @@ public void Main(bool aBool$$ean)

var changes = result.Changes.ToArray();

Assert.Equal(1, changes.Length);
Assert.Single(changes);
Assert.Equal(testFile.FileName, changes[0].FileName);
Assert.Equal(2, changes[0].Changes.Count());
}
Expand Down
10 changes: 5 additions & 5 deletions tests/OmniSharp.Roslyn.CSharp.Tests/SignatureHelpFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ public static void Main(){
}";

var actual = await GetSignatureHelp(source);
Assert.Equal(1, actual.Signatures.Count());
Assert.Single(actual.Signatures);
Assert.Equal(0, actual.ActiveParameter);
Assert.Equal(0, actual.ActiveSignature);
Assert.Equal("NewGuid", actual.Signatures.ElementAt(0).Name);
Assert.Equal(0, actual.Signatures.ElementAt(0).Parameters.Count());
Assert.Empty(actual.Signatures.ElementAt(0).Parameters);
}

[Fact]
Expand All @@ -120,7 +120,7 @@ pubic static Foo(bool b, int n = 1234)
}
}";
var actual = await GetSignatureHelp(source);
Assert.Equal(1, actual.Signatures.Count());
Assert.Single(actual.Signatures);
Assert.Equal(0, actual.ActiveParameter);
Assert.Equal(0, actual.ActiveSignature);

Expand Down Expand Up @@ -395,8 +395,8 @@ public bool B(this Program p, int n)
}";

var actual = await GetSignatureHelp(source);
Assert.Equal(1, actual.Signatures.Count());
Assert.Equal(1, actual.Signatures.ElementAt(actual.ActiveSignature).Parameters.Count());
Assert.Single(actual.Signatures);
Assert.Single(actual.Signatures.ElementAt(actual.ActiveSignature).Parameters);
Assert.Equal("n", actual.Signatures.ElementAt(actual.ActiveSignature).Parameters.ElementAt(0).Name);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/OmniSharp.Roslyn.CSharp.Tests/SnippetFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public MyClass1()
}";

var completions = await FindCompletionsAsync(filename, source, wantSnippet: true);
Assert.Equal(1, completions.Count());
Assert.Single(completions);
ContainsSnippet("Colors$0", completions);
}

Expand All @@ -348,7 +348,7 @@ public MyClass1()
}";

var completions = await FindCompletionsAsync(filename, source, wantSnippet: true);
Assert.Equal(1, completions.Count());
Assert.Single(completions);
ContainsSnippet("TickChanged$0 : TickHandler", completions);
}

Expand Down
6 changes: 3 additions & 3 deletions tests/OmniSharp.Roslyn.CSharp.Tests/StructureFacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public async Task SimpleClass()

var nodes = await GetStructureAsync(source);

Assert.Equal(1, nodes.Length);
Assert.Single(nodes);
Assert.Equal("Far", nodes[0].Location.Text);
Assert.Equal(SyntaxKind.ClassDeclaration.ToString(), nodes.First().Kind);
}
Expand All @@ -43,7 +43,7 @@ public void M() { }


var nodes = await GetStructureAsync(source);
Assert.Equal(1, nodes.Length);
Assert.Single(nodes);
Assert.Equal("Far", nodes[0].Location.Text);
Assert.Equal(SyntaxKind.ClassDeclaration.ToString(), nodes[0].Kind);

Expand All @@ -66,7 +66,7 @@ public async Task SimpleInterface()

var nodes = await GetStructureAsync(source);

Assert.Equal(1, nodes.Length);
Assert.Single(nodes);
Assert.Equal("Far", nodes[0].Location.Text);
Assert.Equal(SyntaxKind.InterfaceDeclaration.ToString(), nodes[0].Kind);
}
Expand Down
Loading

0 comments on commit 90a580f

Please sign in to comment.