-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathApplicationHeaderTests.cs
More file actions
66 lines (58 loc) · 2.04 KB
/
ApplicationHeaderTests.cs
File metadata and controls
66 lines (58 loc) · 2.04 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
58
59
60
61
62
63
64
65
66
// -----------------------------------------------------------------------
// SPDX-FileCopyrightText: 2024 Siemens AG
//
// SPDX-License-Identifier: MIT
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
// -----------------------------------------------------------------------
using Bunit;
using Microsoft.AspNetCore.Components;
using SiemensIXBlazor.Components;
namespace SiemensIXBlazor.Tests
{
public class ApplicationHeaderTests : TestContextBase
{
[Fact]
public void ApplicationHeaderRendersWithoutCrashing()
{
// Arrange
var cut = RenderComponent<ApplicationHeader>(parameters =>
{
parameters.Add(p => p.Name, "testName");
parameters.Add(p => p.Id, "testId");
});
// Assert
cut.MarkupMatches("<ix-application-header id='testId' name='testName'></ix-application-header>");
}
[Fact]
public void ApplicationHeaderRendersChildContent()
{
// Arrange
var expectedContent = "Expected content";
// Act
var cut = RenderComponent<ApplicationHeader>(parameters => parameters
.Add(p => p.ChildContent, builder =>
{
builder.AddContent(0, expectedContent);
})
.Add(p => p.Id, "testId"));
// Assert
Assert.Contains(expectedContent, cut.Markup);
}
[Fact]
public async Task OpenAppSwitchEventWorks()
{
// Arrange
var eventTriggered = false;
var cut = RenderComponent<ApplicationHeader>(
("Id", "headerId"),
("OpenAppSwitchEvent", EventCallback.Factory.Create(this, () => { eventTriggered = true; }))
);
// Act
await cut.InvokeAsync(() => cut.Instance.OpenAppSwitch());
// Assert
Assert.True(eventTriggered);
}
}
}