-
Notifications
You must be signed in to change notification settings - Fork 253
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
73 changed files
with
1,416 additions
and
202 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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 |
---|---|---|
@@ -1,6 +1,4 @@ | ||
# https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-code-owners | ||
|
||
* @Evangelink | ||
|
||
src/Package/MSTest.Sdk @MarcoRossignoli | ||
src/Platform @MarcoRossignoli @Evangelink | ||
src/Platform @MarcoRossignoli @Evangelink |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
param( | ||
[switch]$Force | ||
) | ||
|
||
function Download { | ||
<# | ||
.SYNOPSIS | ||
Downloads a given uri and saves it to outputFile | ||
.DESCRIPTION | ||
Downloads a given uri and saves it to outputFile | ||
PARAMETER uri | ||
The uri to fetch | ||
.PARAMETER outputFile | ||
The outputh file path to save the uri | ||
#> | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
$uri, | ||
|
||
[Parameter(Mandatory = $true)] | ||
$outputFile | ||
) | ||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | ||
$ProgressPreference = 'SilentlyContinue' # Don't display the console progress UI - it's a huge perf hit | ||
|
||
$maxRetries = 5 | ||
$retries = 1 | ||
|
||
while ($true) { | ||
try { | ||
Write-Host "GET $uri" | ||
Invoke-WebRequest $uri -OutFile $outputFile | ||
break | ||
} | ||
catch { | ||
Write-Host "Failed to download '$uri'" | ||
$error = $_.Exception.Message | ||
} | ||
|
||
if (++$retries -le $maxRetries) { | ||
Write-Warning $error -ErrorAction Continue | ||
$delayInSeconds = [math]::Pow(2, $retries) - 1 # Exponential backoff | ||
Write-Host "Retrying. Waiting for $delayInSeconds seconds before next attempt ($retries of $maxRetries)." | ||
Start-Sleep -Seconds $delayInSeconds | ||
} | ||
else { | ||
Write-Error $error -ErrorAction Continue | ||
throw "Unable to download file in $maxRetries attempts." | ||
} | ||
} | ||
|
||
Write-Host "Download of '$uri' complete, saved to $outputFile..." | ||
|
||
} | ||
|
||
function Install-Procdump { | ||
<# | ||
.SYNOPSIS | ||
Installs ProcDump into a folder in this repo. | ||
.DESCRIPTION | ||
This script downloads and extracts the ProcDump. | ||
.PARAMETER Force | ||
Overwrite the existing installation | ||
#> | ||
param( | ||
[switch]$Force | ||
) | ||
$ErrorActionPreference = 'Stop' | ||
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138 | ||
|
||
Set-StrictMode -Version 1 | ||
|
||
$repoRoot = Resolve-Path "$PSScriptRoot\..\.." | ||
$installDir = "$repoRoot\.tools\ProcDump\" | ||
|
||
if (Test-Path "$installDir\procdump.exe") { | ||
if ($Force) { | ||
Remove-Item -Force -Recurse $installDir | ||
} | ||
else { | ||
Write-Host "ProcDump already installed to $installDir. Exiting without action. Call this script again with -Force to overwrite." | ||
exit 0 | ||
} | ||
} | ||
|
||
mkdir $installDir -ea Ignore | out-null | ||
Write-Host "Starting ProcDump download" | ||
Download "https://download.sysinternals.com/files/Procdump.zip" "$installDir/ProcDump.zip" | ||
Write-Host "Done downloading ProcDump" | ||
Expand-Archive "$installDir/ProcDump.zip" -d "$installDir" | ||
Write-Host "Expanded ProcDump to $installDir" | ||
|
||
if ($env:TF_BUILD) { | ||
Write-Host "##vso[task.setvariable variable=PROCDUMP_PATH]$installDir" | ||
Write-Host "##vso[task.prependpath]$installDir" | ||
} | ||
} | ||
|
||
Install-Procdump -Force:$Force |
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
30 changes: 30 additions & 0 deletions
30
samples/public/DemoMSTestSdk/ProjectUsingAspire/IntegrationTest1.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,30 @@ | ||
namespace Aspire.Tests1; | ||
|
||
[TestClass] | ||
public class IntegrationTest1 | ||
{ | ||
// Instructions: | ||
// 1. Add a project reference to the target AppHost project, e.g.: | ||
// | ||
// <ItemGroup> | ||
// <ProjectReference Include="../MyAspireApp.AppHost/MyAspireApp.AppHost.csproj" /> | ||
// </ItemGroup> | ||
// | ||
// 2. Uncomment the following example test and update 'Projects.MyAspireApp_AppHost' to match your AppHost project: | ||
// | ||
// [TestMethod] | ||
// public async Task GetWebResourceRootReturnsOkStatusCode() | ||
// { | ||
// // Arrange | ||
// var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.MyAspireApp_AppHost>(); | ||
// await using var app = await appHost.BuildAsync(); | ||
// await app.StartAsync(); | ||
|
||
// // Act | ||
// var httpClient = app.CreateHttpClient("webfrontend"); | ||
// var response = await httpClient.GetAsync("/"); | ||
|
||
// // Assert | ||
// Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); | ||
// } | ||
} |
44 changes: 44 additions & 0 deletions
44
samples/public/DemoMSTestSdk/ProjectUsingAspire/ProjectUsingAspire.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,44 @@ | ||
<Project Sdk="MSTest.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
<!-- By default, MSTest Sdk uses MSTest runner --> | ||
<EnableAspireTesting>true</EnableAspireTesting> | ||
</PropertyGroup> | ||
|
||
</Project> | ||
|
||
<!-- | ||
Below is the equivalent project configuration when not using MSTest.Sdk | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
<EnableMSTestRunner>true</EnableMSTestRunner> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Aspire.Hosting.Testing" Version="$(AspireTestingVersion)" /> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(VSTestVersion)" /> | ||
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" Version="$(CodeCoverageVersion)" /> | ||
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="$(TestingPlatformVersion)" /> | ||
<PackageReference Include="MSTest.Analyzers" Version="$(MSTestVersion)" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="$(MSTestVersion)" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="$(MSTestVersion)" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Using Include="Aspire.Hosting.Testing" /> | ||
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" /> | ||
</ItemGroup> | ||
</Project> | ||
--> |
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
4 changes: 0 additions & 4 deletions
4
samples/public/DemoMSTestSdk/ProjectUsingMSTestRunner/Usings.cs
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
samples/public/DemoMSTestSdk/ProjectUsingPlaywright/ProjectUsingPlaywright.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,45 @@ | ||
<Project Sdk="MSTest.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
<!-- By default, MSTest Sdk uses MSTest runner --> | ||
<EnablePlaywright>true</EnablePlaywright> | ||
</PropertyGroup> | ||
|
||
</Project> | ||
|
||
|
||
<!-- | ||
Below is the equivalent project configuration when not using MSTest.Sdk | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
<EnableMSTestRunner>true</EnableMSTestRunner> | ||
<OutputType>Exe</OutputType> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(VSTestVersion)" /> | ||
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" Version="$(CodeCoverageVersion)" /> | ||
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="$(TestingPlatformVersion)" /> | ||
<PackageReference Include="MSTest.TestAdapter" Version="$(MSTestVersion)" /> | ||
<PackageReference Include="MSTest.TestFramework" Version="$(MSTestVersion)" /> | ||
<PackageReference Include="Microsoft.Playwright.MSTest" Version="$(PlaywrightVersion)" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" /> | ||
</ItemGroup> | ||
</Project> | ||
--> |
33 changes: 33 additions & 0 deletions
33
samples/public/DemoMSTestSdk/ProjectUsingPlaywright/UnitTest1.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,33 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System.Text.RegularExpressions; | ||
|
||
using Microsoft.Playwright; | ||
|
||
namespace ProjectUsingPlaywright; | ||
|
||
[TestClass] | ||
public class UnitTest1 : PageTest | ||
{ | ||
[TestMethod] | ||
public async Task HomepageHasPlaywrightInTitleAndGetStartedLinkLinkingToTheIntroPage() | ||
{ | ||
await Page.GotoAsync("https://playwright.dev"); | ||
|
||
// Expect a title "to contain" a substring. | ||
await Expect(Page).ToHaveTitleAsync(new Regex("Playwright")); | ||
|
||
// create a locator | ||
ILocator getStarted = Page.Locator("text=Get Started"); | ||
|
||
// Expect an attribute "to be strictly equal" to the value. | ||
await Expect(getStarted).ToHaveAttributeAsync("href", "/docs/intro"); | ||
|
||
// Click the get started link. | ||
await getStarted.ClickAsync(); | ||
|
||
// Expects the URL to contain intro. | ||
await Expect(Page).ToHaveURLAsync(new Regex(".*intro")); | ||
} | ||
} |
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
Oops, something went wrong.