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

Add SDK samples from rel/3.4 #3074

Merged
merged 3 commits into from
Jun 10, 2024
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
18 changes: 15 additions & 3 deletions samples/public/DemoMSTestSdk/DemoMSTestSdk.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.34807.42
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectUsingVSTest", "ProjectUsingVSTest\ProjectUsingVSTest.csproj", "{0360A072-0ED6-4A27-9AE5-3C6DD055733E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectUsingVSTest", "ProjectUsingVSTest\ProjectUsingVSTest.csproj", "{0360A072-0ED6-4A27-9AE5-3C6DD055733E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectUsingMSTestRunner", "ProjectUsingMSTestRunner\ProjectUsingMSTestRunner.csproj", "{8DA3F43B-938F-4A1E-BE58-B7F80386187F}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectUsingMSTestRunner", "ProjectUsingMSTestRunner\ProjectUsingMSTestRunner.csproj", "{8DA3F43B-938F-4A1E-BE58-B7F80386187F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectWithNativeAOT", "ProjectWithNativeAOT\ProjectWithNativeAOT.csproj", "{9EA03738-C4AA-4CD7-BF71-BA8E689522D7}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectWithNativeAOT", "ProjectWithNativeAOT\ProjectWithNativeAOT.csproj", "{9EA03738-C4AA-4CD7-BF71-BA8E689522D7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectUsingPlaywright", "ProjectUsingPlaywright\ProjectUsingPlaywright.csproj", "{D047E30F-BEC1-496A-A84B-D27E0966F7DD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectUsingAspire", "ProjectUsingAspire\ProjectUsingAspire.csproj", "{274001A3-B33E-4235-92D4-1A8F39595F5F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -27,6 +31,14 @@ Global
{9EA03738-C4AA-4CD7-BF71-BA8E689522D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9EA03738-C4AA-4CD7-BF71-BA8E689522D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9EA03738-C4AA-4CD7-BF71-BA8E689522D7}.Release|Any CPU.Build.0 = Release|Any CPU
{D047E30F-BEC1-496A-A84B-D27E0966F7DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D047E30F-BEC1-496A-A84B-D27E0966F7DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D047E30F-BEC1-496A-A84B-D27E0966F7DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D047E30F-BEC1-496A-A84B-D27E0966F7DD}.Release|Any CPU.Build.0 = Release|Any CPU
{274001A3-B33E-4235-92D4-1A8F39595F5F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{274001A3-B33E-4235-92D4-1A8F39595F5F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{274001A3-B33E-4235-92D4-1A8F39595F5F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{274001A3-B33E-4235-92D4-1A8F39595F5F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
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);
// }
}
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>
-->
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,9 @@ Below is the equivalent project configuration when not using MSTest.Sdk
<PackageReference Include="MSTest.TestFramework" Version="$(MSTestVersion)" />
</ItemGroup>

<ItemGroup>
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>

</Project>
-->

This file was deleted.

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 samples/public/DemoMSTestSdk/ProjectUsingPlaywright/UnitTest1.cs
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"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@ Below is the equivalent project configuration when not using MSTest.Sdk
<PackageReference Include="MSTest.TestFramework" Version="$(MSTestVersion)" />
</ItemGroup>

<ItemGroup>
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>

</Project>
-->
4 changes: 0 additions & 4 deletions samples/public/DemoMSTestSdk/ProjectUsingVSTest/Usings.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,9 @@ Below is the equivalent project configuration when not using MSTest.Sdk
<PackageReference Include="MSTest.TestFramework" Version="$(MSTestVersion)" />
</ItemGroup>

<ItemGroup>
<Using Include="Microsoft.VisualStudio.TestTools.UnitTesting" />
</ItemGroup>

</Project>
-->
4 changes: 0 additions & 4 deletions samples/public/DemoMSTestSdk/ProjectWithNativeAOT/Usings.cs

This file was deleted.

4 changes: 3 additions & 1 deletion samples/public/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<Project>

<PropertyGroup>
<AspireTestingVersion>8.0.1</AspireTestingVersion>
<CodeCoverageVersion>17.10.4</CodeCoverageVersion>
<MSTestVersion>3.4.0</MSTestVersion>
<MSTestVersion>3.4.3</MSTestVersion>
<MSTestAOTVersion>1.0.0-alpha.24163.4</MSTestAOTVersion>
<PlaywrightVersion>1.44.0</PlaywrightVersion>
<TestingPlatformVersion>1.2.1</TestingPlatformVersion>
<VSTestVersion>17.10.0</VSTestVersion>
</PropertyGroup>
Expand Down