-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathMenuAboutTest.cs
More file actions
64 lines (55 loc) · 2.19 KB
/
MenuAboutTest.cs
File metadata and controls
64 lines (55 loc) · 2.19 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
// -----------------------------------------------------------------------
// 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 Microsoft.AspNetCore.Components.Web;
namespace SiemensIXBlazor.Tests.MenuAbout
{
public class MenuAboutTest: TestContextBase
{
[Fact]
public void ComponentRendersWithoutCrashing()
{
// Arrange
var cut = RenderComponent<Components.MenuAbout.MenuAbout>(parameters => parameters
.Add(p => p.Id, "testId"));
// Assert
cut.MarkupMatches("<ix-menu-about label=\"About & legal information\" id=\"testId\"></ix-menu-about>");
}
[Fact]
public void ChildContentPropertyIsSetCorrectly()
{
// Arrange
var cut = RenderComponent<Components.MenuAbout.MenuAbout>(parameters => parameters.Add(p => p.ChildContent, (RenderFragment)(builder => builder.AddMarkupContent(0, "Test content")))
.Add(p => p.Id, "testId"));
// Assert
Assert.NotNull(cut.Instance.ChildContent);
}
[Fact]
public void IdPropertyIsSetCorrectly()
{
// Arrange
var cut = RenderComponent<Components.MenuAbout.MenuAbout>(parameters => parameters.Add(p => p.Id, "testId"));
// Assert
Assert.Equal("testId", cut.Instance.Id);
}
[Fact]
public void ClosedEventTriggeredCorrectly()
{
// Arrange
var eventTriggered = false;
var cut = RenderComponent<Components.MenuAbout.MenuAbout>(parameters => parameters.Add(p => p.ClosedEvent, EventCallback.Factory.Create<MouseEventArgs>(this, () => eventTriggered = true))
.Add(p => p.Id, "testId"));
// Act
cut.Instance.ClosedEvent.InvokeAsync(new MouseEventArgs());
// Assert
Assert.True(eventTriggered);
}
}
}