Skip to content

Commit f56b65d

Browse files
Added test project.
1 parent bc33dae commit f56b65d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+672
-0
lines changed

Blazor.WebAudio.sln

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KristofferStrube.Blazor.Web
77
EndProject
88
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KristofferStrube.Blazor.WebAudio.WasmExample", "samples\KristofferStrube.Blazor.WebAudio.WasmExample\KristofferStrube.Blazor.WebAudio.WasmExample.csproj", "{B0FCE7ED-FCC5-4140-B732-2ABEC4848441}"
99
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorServer", "tests\BlazorServer\BlazorServer.csproj", "{9049D654-2EA4-5D01-BC0A-F26D2803F0EF}"
13+
EndProject
14+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationTests", "tests\IntegrationTests\IntegrationTests.csproj", "{FF77485D-96D1-B1AA-B58F-3986BE3ADB27}"
15+
EndProject
1016
Global
1117
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1218
Debug|Any CPU = Debug|Any CPU
@@ -21,10 +27,22 @@ Global
2127
{B0FCE7ED-FCC5-4140-B732-2ABEC4848441}.Debug|Any CPU.Build.0 = Debug|Any CPU
2228
{B0FCE7ED-FCC5-4140-B732-2ABEC4848441}.Release|Any CPU.ActiveCfg = Release|Any CPU
2329
{B0FCE7ED-FCC5-4140-B732-2ABEC4848441}.Release|Any CPU.Build.0 = Release|Any CPU
30+
{9049D654-2EA4-5D01-BC0A-F26D2803F0EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31+
{9049D654-2EA4-5D01-BC0A-F26D2803F0EF}.Debug|Any CPU.Build.0 = Debug|Any CPU
32+
{9049D654-2EA4-5D01-BC0A-F26D2803F0EF}.Release|Any CPU.ActiveCfg = Release|Any CPU
33+
{9049D654-2EA4-5D01-BC0A-F26D2803F0EF}.Release|Any CPU.Build.0 = Release|Any CPU
34+
{FF77485D-96D1-B1AA-B58F-3986BE3ADB27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35+
{FF77485D-96D1-B1AA-B58F-3986BE3ADB27}.Debug|Any CPU.Build.0 = Debug|Any CPU
36+
{FF77485D-96D1-B1AA-B58F-3986BE3ADB27}.Release|Any CPU.ActiveCfg = Release|Any CPU
37+
{FF77485D-96D1-B1AA-B58F-3986BE3ADB27}.Release|Any CPU.Build.0 = Release|Any CPU
2438
EndGlobalSection
2539
GlobalSection(SolutionProperties) = preSolution
2640
HideSolutionNode = FALSE
2741
EndGlobalSection
42+
GlobalSection(NestedProjects) = preSolution
43+
{9049D654-2EA4-5D01-BC0A-F26D2803F0EF} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
44+
{FF77485D-96D1-B1AA-B58F-3986BE3ADB27} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
45+
EndGlobalSection
2846
GlobalSection(ExtensibilityGlobals) = postSolution
2947
SolutionGuid = {E26435BB-DA9F-4DB2-BDD3-194062FCBB71}
3048
EndGlobalSection

tests/BlazorServer/App.razor

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Router AppAssembly="@typeof(App).Assembly">
2+
<Found Context="routeData">
3+
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4+
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
5+
</Found>
6+
<NotFound>
7+
<PageTitle>Not found</PageTitle>
8+
<LayoutView Layout="@typeof(MainLayout)">
9+
<p role="alert">Sorry, there's nothing at this address.</p>
10+
</LayoutView>
11+
</NotFound>
12+
</Router>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net9.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\..\src\KristofferStrube.Blazor.WebAudio\KristofferStrube.Blazor.WebAudio.csproj" />
11+
</ItemGroup>
12+
13+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+

2+
namespace BlazorServer;
3+
4+
public class EvaluationContext : IEvaluationContext<EvaluationContext>
5+
{
6+
public object? Result { get; set; }
7+
8+
public Exception? Exception { get; set; }
9+
10+
public Func<Task<object?>>? AfterRenderAsync { get; set; }
11+
12+
public static EvaluationContext Create(IServiceProvider provider)
13+
{
14+
return new EvaluationContext();
15+
}
16+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace BlazorServer;
2+
3+
public interface IEvaluationContext<T> where T : EvaluationContext, IEvaluationContext<T>
4+
{
5+
public static abstract T Create(IServiceProvider provider);
6+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@inherits LayoutComponentBase
2+
3+
<main> @Body </main>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@page "/"
2+
3+
<span data-testid="result">@result</span>
4+
5+
@code {
6+
string? result;
7+
8+
[Inject]
9+
public required EvaluationContext EvaluationContext { get; set; }
10+
11+
protected override async Task OnAfterRenderAsync(bool firstRender)
12+
{
13+
if (!firstRender) return;
14+
try
15+
{
16+
if (EvaluationContext.AfterRenderAsync is not null)
17+
{
18+
EvaluationContext.Result = await EvaluationContext.AfterRenderAsync.Invoke();
19+
}
20+
}
21+
catch (Exception e)
22+
{
23+
EvaluationContext.Exception = e;
24+
}
25+
result = "done";
26+
StateHasChanged();
27+
}
28+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@page "/"
2+
@using Microsoft.AspNetCore.Components.Web
3+
@namespace BlazorServer.Pages
4+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
5+
6+
<!DOCTYPE html>
7+
<html lang="en">
8+
<head>
9+
<meta charset="utf-8" />
10+
<base href="~/" />
11+
<link href="css/site.css" rel="stylesheet" />
12+
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
13+
</head>
14+
<body>
15+
<component type="typeof(App)" render-mode="ServerPrerendered" />
16+
17+
<div id="blazor-error-ui">
18+
<environment include="Staging,Production">
19+
An error has occurred. This application may no longer respond until reloaded.
20+
</environment>
21+
<environment include="Development">
22+
An unhandled exception has occurred. See browser dev tools for details.
23+
</environment>
24+
<a href="" class="reload">Reload</a>
25+
<a class="dismiss">🗙</a>
26+
</div>
27+
28+
<script src="_framework/blazor.server.js"></script>
29+
</body>
30+
</html>

tests/BlazorServer/Program.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace BlazorServer;
2+
3+
public class Program
4+
{
5+
private static async Task Main(string[] args)
6+
{
7+
var host = BuildWebHost(args, _ => { });
8+
await host.RunAsync();
9+
}
10+
11+
public static IHost BuildWebHost(string[] args, Action<IServiceCollection> configureServices)
12+
=> Host.CreateDefaultBuilder(args)
13+
.ConfigureWebHostDefaults(builder =>
14+
{
15+
builder.UseStaticWebAssets();
16+
builder.UseStartup<Startup>();
17+
builder.ConfigureServices(configureServices);
18+
})
19+
.Build();
20+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"iisSettings": {
3+
"iisExpress": {
4+
"applicationUrl": "http://localhost:1729",
5+
"sslPort": 44325
6+
}
7+
},
8+
"profiles": {
9+
"http": {
10+
"commandName": "Project",
11+
"dotnetRunMessages": true,
12+
"launchBrowser": true,
13+
"applicationUrl": "http://localhost:5151",
14+
"environmentVariables": {
15+
"ASPNETCORE_ENVIRONMENT": "Development"
16+
}
17+
},
18+
"https": {
19+
"commandName": "Project",
20+
"dotnetRunMessages": true,
21+
"launchBrowser": true,
22+
"applicationUrl": "https://localhost:7131;http://localhost:5151",
23+
"environmentVariables": {
24+
"ASPNETCORE_ENVIRONMENT": "Development"
25+
}
26+
},
27+
"IIS Express": {
28+
"commandName": "IISExpress",
29+
"launchBrowser": true,
30+
"environmentVariables": {
31+
"ASPNETCORE_ENVIRONMENT": "Development"
32+
}
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)