-
Notifications
You must be signed in to change notification settings - Fork 790
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
952 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
vsintegration/tests/FSharp.Editor.IntegrationTests/AbstractIntegrationTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// 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 Microsoft.VisualStudio.Extensibility.Testing; | ||
using Xunit; | ||
|
||
namespace Microsoft.CodeAnalysis.Testing | ||
{ | ||
[IdeSettings(MinVersion = VisualStudioVersion.VS2022)] | ||
public abstract class AbstractIntegrationTest : AbstractIdeIntegrationTest | ||
{ | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
vsintegration/tests/FSharp.Editor.IntegrationTests/BuildProjectTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// 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 Microsoft.CodeAnalysis.Testing; | ||
using Microsoft.VisualStudio.Extensibility.Testing; | ||
using Microsoft.VisualStudio.Shell.Interop; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace FSharp.Editor.IntegrationTests; | ||
|
||
public class BuildProjectTests : AbstractIntegrationTest | ||
{ | ||
[IdeFact] | ||
public async Task SuccessfulBuild_Async() | ||
{ | ||
var token = HangMitigatingCancellationToken; | ||
var template = WellKnownProjectTemplates.FSharpNetCoreClassLibrary; | ||
var solutionExplorer = TestServices.SolutionExplorer; | ||
var editor = TestServices.Editor; | ||
var code = """ | ||
module Test | ||
let answer = 42 | ||
"""; | ||
|
||
var expectedBuildSummary = "========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped =========="; | ||
|
||
await solutionExplorer.CreateSolutionAsync(nameof(BuildProjectTests), token); | ||
await solutionExplorer.AddProjectAsync("Library", template, token); | ||
await solutionExplorer.RestoreNuGetPackagesAsync(token); | ||
await editor.SetTextAsync(code, token); | ||
|
||
var actualBuildSummary = await solutionExplorer.BuildSolutionAsync(token); | ||
|
||
Assert.Contains(expectedBuildSummary, actualBuildSummary); | ||
} | ||
|
||
[IdeFact] | ||
public async Task FailedBuild_Async() | ||
{ | ||
var token = HangMitigatingCancellationToken; | ||
var template = WellKnownProjectTemplates.FSharpNetCoreClassLibrary; | ||
var solutionExplorer = TestServices.SolutionExplorer; | ||
var editor = TestServices.Editor; | ||
var errorList = TestServices.ErrorList; | ||
var code = """ | ||
module Test | ||
let answer = | ||
"""; | ||
|
||
var expectedBuildSummary = "========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========="; | ||
var expectedError = "(Compiler) Library.fs(3, 1): error FS0010: Incomplete structured construct at or before this point in binding"; | ||
|
||
await solutionExplorer.CreateSolutionAsync(nameof(BuildProjectTests), token); | ||
await solutionExplorer.AddProjectAsync("Library", template, token); | ||
await solutionExplorer.RestoreNuGetPackagesAsync(token); | ||
await editor.SetTextAsync(code, token); | ||
|
||
var actualBuildSummary = await solutionExplorer.BuildSolutionAsync(token); | ||
Assert.Contains(expectedBuildSummary, actualBuildSummary); | ||
|
||
await errorList.ShowBuildErrorsAsync(token); | ||
var errors = await errorList.GetBuildErrorsAsync(__VSERRORCATEGORY.EC_ERROR, token); | ||
Assert.Contains(expectedError, errors); | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
vsintegration/tests/FSharp.Editor.IntegrationTests/CreateProjectTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// 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 Microsoft.CodeAnalysis.Testing; | ||
using Microsoft.VisualStudio.Extensibility.Testing; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace FSharp.Editor.IntegrationTests; | ||
|
||
public class CreateProjectTests : AbstractIntegrationTest | ||
{ | ||
[IdeFact] | ||
public async Task ClassLibrary_Async() | ||
{ | ||
var token = HangMitigatingCancellationToken; | ||
var template = WellKnownProjectTemplates.FSharpNetCoreClassLibrary; | ||
var solutionExplorer = TestServices.SolutionExplorer; | ||
var editor = TestServices.Editor; | ||
|
||
var expectedCode = """ | ||
namespace Library | ||
module Say = | ||
let hello name = | ||
printfn "Hello %s" name | ||
"""; | ||
|
||
await solutionExplorer.CreateSolutionAsync(nameof(CreateProjectTests), token); | ||
await solutionExplorer.AddProjectAsync("Library", template, token); | ||
|
||
var actualCode = await editor.GetTextAsync(token); | ||
|
||
Assert.Equal(expectedCode, actualCode); | ||
} | ||
|
||
[IdeFact] | ||
public async Task ConsoleApp_Async() | ||
{ | ||
var token = HangMitigatingCancellationToken; | ||
var template = WellKnownProjectTemplates.FSharpNetCoreConsoleApplication; | ||
var solutionExplorer = TestServices.SolutionExplorer; | ||
var editor = TestServices.Editor; | ||
|
||
var expectedCode = """ | ||
// For more information see https://aka.ms/fsharp-console-apps | ||
printfn "Hello from F#" | ||
"""; | ||
|
||
await solutionExplorer.CreateSolutionAsync(nameof(CreateProjectTests), token); | ||
await solutionExplorer.AddProjectAsync("ConsoleApp", template, token); | ||
|
||
var actualCode = await editor.GetTextAsync(token); | ||
|
||
Assert.Equal(expectedCode, actualCode); | ||
} | ||
|
||
[IdeFact] | ||
public async Task XUnitTestProject_Async() | ||
{ | ||
var token = HangMitigatingCancellationToken; | ||
var template = WellKnownProjectTemplates.FSharpNetCoreXUnitTest; | ||
var solutionExplorer = TestServices.SolutionExplorer; | ||
var editor = TestServices.Editor; | ||
|
||
var expectedCode = """ | ||
module Tests | ||
open System | ||
open Xunit | ||
[<Fact>] | ||
let ``My test`` () = | ||
Assert.True(true) | ||
"""; | ||
|
||
await solutionExplorer.CreateSolutionAsync(nameof(CreateProjectTests), token); | ||
await solutionExplorer.AddProjectAsync("ConsoleApp", template, token); | ||
|
||
var actualCode = await editor.GetTextAsync(token); | ||
|
||
Assert.Equal(expectedCode, actualCode); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
vsintegration/tests/FSharp.Editor.IntegrationTests/FSharp.Editor.IntegrationTests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net472</TargetFramework> | ||
<LangVersion>preview</LangVersion> | ||
<Nullable>enable</Nullable> | ||
<UnitTestType>xunit</UnitTestType> | ||
<IsPackable>false</IsPackable> | ||
<GenerateProgramFile>false</GenerateProgramFile> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="xunit.runner.json" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="xunit.runner.json"> | ||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
</Content> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.VisualStudio.Editor" Version="$(MicrosoftVisualStudioEditorVersion)" /> | ||
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Testing.Xunit" Version="$(MicrosoftVisualStudioExtensibilityTestingSourceGeneratorVersion)" /> | ||
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Testing.SourceGenerator" Version="$(MicrosoftVisualStudioExtensibilityTestingSourceGeneratorVersion)" /> | ||
<PackageReference Include="Microsoft.VisualStudio.Language.Intellisense" Version="$(MicrosoftVisualStudioLanguageIntellisenseVersion)" /> | ||
<PackageReference Include="NuGet.SolutionRestoreManager.Interop" Version="$(NuGetSolutionRestoreManagerInteropVersion)" /> | ||
<PackageReference Include="Nullable" Version="1.3.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.