-
-
Notifications
You must be signed in to change notification settings - Fork 70
/
DemosSmokeTests.cs
47 lines (40 loc) · 1.23 KB
/
DemosSmokeTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using Bunit;
using Havit.Blazor.Documentation.DemoData;
using Havit.Blazor.Documentation.Shared.Components;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Rendering;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Havit.Blazor.Documentation.Tests;
[TestClass]
public class DemosSmokeTests
{
[DataTestMethod]
[DynamicData(nameof(GetDemos), DynamicDataSourceType.Method)]
public void DocumentationDemo_SmokeTest(Type demoComponent)
{
// Arrange
var ctx = new Bunit.TestContext();
ctx.JSInterop.Mode = JSRuntimeMode.Loose;
ctx.Services.AddLogging();
ctx.Services.AddHxServices();
ctx.Services.AddHxMessenger();
ctx.Services.AddHxMessageBoxHost();
ctx.Services.AddTransient<IDemoDataService, DemoDataService>();
RenderFragment componentRenderer = (RenderTreeBuilder builder) =>
{
builder.OpenComponent(1, demoComponent);
builder.CloseComponent();
};
// Act
ctx.Render(componentRenderer);
// Assert
// Smoke test - no exception should occur
}
public static IEnumerable<object[]> GetDemos()
{
return typeof(Demo).Assembly.GetTypes()
.Where(t => t.Name.Contains("_Demo"))
.Select(t => new object[] { t });
}
}