-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathRenderTests.cs
More file actions
57 lines (51 loc) · 1.49 KB
/
RenderTests.cs
File metadata and controls
57 lines (51 loc) · 1.49 KB
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
48
49
50
51
52
53
54
55
56
57
using AwesomeAssertions;
using Bunit;
using Microsoft.AspNetCore.Components;
using MudBlazor.Services;
using MudExtensions.Utilities;
using System.Reflection;
namespace MudExtensions.UnitTests.Components;
[TestFixture]
public class ComponentsRenderTests : BunitTest
{
public static IEnumerable<Type> ComponentTypes()
{
var assembly = typeof(MudExtensions.MudColorProvider).Assembly;
return assembly
.GetTypes()
.Where(t =>
t.IsClass &&
!t.IsAbstract &&
!t.IsGenericTypeDefinition &&
typeof(IComponent).IsAssignableFrom(t) &&
t.IsPublic &&
t.GetCustomAttribute<ExcludeFromSmokeTest>() == null);
}
[SetUp]
public void Setup()
{
Context.Services.AddMudServices();
Context.JSInterop.Mode = JSRuntimeMode.Loose;
}
[TestCaseSource(nameof(ComponentTypes))]
public void Component_Should_Render(Type componentType)
{
try
{
var cut = Context.Render(builder =>
{
builder.OpenComponent(0, componentType);
builder.CloseComponent();
});
cut.Should().NotBeNull();
}
catch (Exception ex)
{
Assert.Fail(
$"Component render FAILED: {componentType.FullName}\n" +
$"Exception: {ex.GetType().Name}\n" +
$"Message: {ex.Message}"
);
}
}
}