Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port more tests #59587

Merged
merged 7 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<RoslynDiagnosticsNugetPackageVersion>3.3.3-beta1.21105.3</RoslynDiagnosticsNugetPackageVersion>
<MicrosoftCodeAnalysisNetAnalyzersVersion>6.0.0-rc1.21366.2</MicrosoftCodeAnalysisNetAnalyzersVersion>
<MicrosoftCodeAnalysisTestingVersion>1.1.1-beta1.22081.4</MicrosoftCodeAnalysisTestingVersion>
<MicrosoftVisualStudioExtensibilityTestingVersion>0.1.124-beta</MicrosoftVisualStudioExtensibilityTestingVersion>
<MicrosoftVisualStudioExtensibilityTestingVersion>0.1.127-beta</MicrosoftVisualStudioExtensibilityTestingVersion>
<!-- CodeStyleAnalyzerVersion should we updated together with version of dotnet-format in dotnet-tools.json -->
<CodeStyleAnalyzerVersion>4.0.1</CodeStyleAnalyzerVersion>
<VisualStudioEditorPackagesVersion>16.10.230</VisualStudioEditorPackagesVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/Source/RunTests/ProcessTestExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ private async Task<TestResult> RunTestAsyncInternal(AssemblyInfo assemblyInfo, b
}
}

Logger.Log($"Command line {assemblyInfo.DisplayName}: {Options.DotnetFilePath} {commandLineArguments}");
Logger.Log($"Command line {assemblyInfo.DisplayName} completed in {span.TotalSeconds} seconds: {Options.DotnetFilePath} {commandLineArguments}");
var standardOutput = string.Join(Environment.NewLine, xunitProcessResult.OutputLines) ?? "";
var errorOutput = string.Join(Environment.NewLine, xunitProcessResult.ErrorLines) ?? "";

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,23 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Xml.Linq;
using Microsoft.VisualStudio.IntegrationTest.Utilities;
using Xunit;
using Xunit.Abstractions;
using ProjectUtils = Microsoft.VisualStudio.IntegrationTest.Utilities.Common.ProjectUtils;

namespace Roslyn.VisualStudio.IntegrationTests
{
public abstract class AbstractUpdateProjectTest : AbstractIntegrationTest
public abstract class AbstractUpgradeProjectTest : AbstractIntegrationTest
{
protected AbstractUpdateProjectTest(VisualStudioInstanceFactory instanceFactory)
: base(instanceFactory)
{
}

protected XElement GetProjectFileElement(ProjectUtils.Project project)
protected async Task<XElement> GetProjectFileElementAsync(string projectName, CancellationToken cancellationToken)
{
// Save the project file.
VisualStudio.SolutionExplorer.SaveAll();
await TestServices.SolutionExplorer.SaveAllAsync(cancellationToken);

var projectFileContent = VisualStudio.SolutionExplorer.GetFileContents(project, Path.GetFileName(project.RelativePath));
var projectFileContent = await TestServices.SolutionExplorer.GetFileContentsAsync(projectName, $"{ProjectName}.csproj", cancellationToken);
return XElement.Parse(projectFileContent);
}

Expand All @@ -50,7 +42,7 @@ static bool IsConditionalPropertyGroup(XElement element)
=> element.Name.LocalName == "PropertyGroup" && element.Attributes().Any(a => a.Name.LocalName == "Condition");
}

private static string GetPropertyValue(XElement propertyGroup, string propertyName)
private static string? GetPropertyValue(XElement propertyGroup, string propertyName)
=> propertyGroup.Elements().SingleOrDefault(e => e.Name.LocalName == propertyName)?.Value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,26 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.VisualStudio.IntegrationTest.Utilities;
using Roslyn.Test.Utilities;
using Xunit;
using Xunit.Abstractions;

namespace Roslyn.VisualStudio.IntegrationTests.CSharp
{
[Collection(nameof(SharedIntegrationHostFixture))]
[Trait(Traits.Feature, Traits.Features.F1Help)]
public class CSharpF1Help : AbstractEditorTest
{
protected override string LanguageName => LanguageNames.CSharp;

public CSharpF1Help(VisualStudioInstanceFactory instanceFactory)
: base(instanceFactory, nameof(CSharpF1Help))
public CSharpF1Help()
: base(nameof(CSharpF1Help))
{
}

[WpfFact, Trait(Traits.Feature, Traits.Features.F1Help)]
private void F1Help()
[IdeFact]
private async Task F1Help()
{
var text = @"
using System;
Expand Down Expand Up @@ -69,17 +66,17 @@ group n by n % 5 into g
#endregion TaoRegion
}";

SetUpEditor(text);
Verify("abstract", "abstract_CSharpKeyword");
Verify("ascending", "ascending_CSharpKeyword");
Verify("from", "from_CSharpKeyword");
Verify("First();", "System.Linq.Enumerable.First``1");
await SetUpEditorAsync(text, HangMitigatingCancellationToken);
await VerifyAsync("abstract", "abstract_CSharpKeyword", HangMitigatingCancellationToken);
await VerifyAsync("ascending", "ascending_CSharpKeyword", HangMitigatingCancellationToken);
await VerifyAsync("from", "from_CSharpKeyword", HangMitigatingCancellationToken);
await VerifyAsync("First();", "System.Linq.Enumerable.First``1", HangMitigatingCancellationToken);
}

private void Verify(string word, string expectedKeyword)
private async Task VerifyAsync(string word, string expectedKeyword, CancellationToken cancellationToken)
{
VisualStudio.Editor.PlaceCaret(word, charsOffset: -1);
Assert.Contains(expectedKeyword, VisualStudio.Editor.GetF1Keyword());
await TestServices.Editor.PlaceCaretAsync(word, charsOffset: -1, cancellationToken);
Assert.Contains(expectedKeyword, await TestServices.Editor.GetF1KeywordsAsync(cancellationToken));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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.

using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Test.Utilities;
using Xunit;

namespace Roslyn.VisualStudio.IntegrationTests.CSharp
{
[Trait(Traits.Feature, Traits.Features.GoToBase)]
public class CSharpGoToBase : AbstractEditorTest
{
protected override string LanguageName => LanguageNames.CSharp;

public CSharpGoToBase()
: base(nameof(CSharpGoToBase))
{
}

[IdeFact]
public async Task GoToBaseFromMetadataAsSource()
{
await TestServices.SolutionExplorer.AddFileAsync(ProjectName, "C.cs", cancellationToken: HangMitigatingCancellationToken);
await TestServices.SolutionExplorer.OpenFileAsync(ProjectName, "C.cs", HangMitigatingCancellationToken);
await TestServices.Editor.SetTextAsync(
@"using System;

class C
{
public override string ToString()
{
return ""C"";
}
}", HangMitigatingCancellationToken);
await TestServices.Editor.PlaceCaretAsync("ToString", charsOffset: -1, HangMitigatingCancellationToken);
await TestServices.Editor.GoToBaseAsync(HangMitigatingCancellationToken);
Assert.Equal("Object [from metadata]", await TestServices.Shell.GetActiveWindowCaptionAsync(HangMitigatingCancellationToken));

await TestServices.EditorVerifier.TextContainsAsync(@"public virtual string ToString$$()", assertCaretPosition: true);
}
}
}
Loading