-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from yagizhanNY/test/gokce-unitTest
test: Unit tests are added for the components beginning with MenuSett…
- Loading branch information
Showing
32 changed files
with
1,247 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Bunit; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using SiemensIXBlazor.Components; | ||
using Microsoft.AspNetCore.Components; | ||
|
||
|
||
namespace SiemensIXBlazor.Tests.MenuSettings | ||
|
||
|
||
public class MenuSettingsItemTests : TestContext | ||
{ | ||
|
||
public void MenuSettingsItemRendersCorrectly() | ||
{ | ||
// Arrange | ||
using var ctx = new TestContext(); | ||
|
||
RenderFragment childContent = builder => | ||
{ | ||
builder.AddContent(0, "Test Content"); | ||
}; | ||
|
||
// Act | ||
var cut = ctx.RenderComponent<MenuSettingsItem>(parameters => parameters | ||
.Add(p => p.Label, "Test Label") | ||
.Add(p => p.ChildContent, childContent)); | ||
|
||
// Assert | ||
cut.MarkupMatches("<ix-menu-settings-item label=\"Test Label\">Test Content</ix-menu-settings-item>"); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
SiemensIXBlazor.Tests/MenuSettings/MenuSettingsItemTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Bunit; | ||
using Microsoft.AspNetCore.Components; | ||
using SiemensIXBlazor.Components.MenuSettings; | ||
|
||
namespace SiemensIXBlazor.Tests.MenuSettings | ||
{ | ||
public class MenuSettingsItemTests : TestContextBase | ||
{ | ||
[Fact] | ||
public void MenuSettingsItemRendersCorrectly() | ||
{ | ||
// Arrange | ||
RenderFragment childContent = builder => | ||
{ | ||
builder.AddContent(0, "Simple Text"); | ||
}; | ||
|
||
// Act | ||
var cut = RenderComponent<MenuSettingsItem>( | ||
("Label", "Test Label"), | ||
("ChildContent", childContent)); | ||
|
||
// Assert | ||
cut.MarkupMatches("<ix-menu-settings-item label=\"Test Label\">Simple Text</ix-menu-settings-item>"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Bunit; | ||
using SiemensIXBlazor.Components; | ||
using Microsoft.AspNetCore.Components; | ||
using SiemensIXBlazor.Components.MenuSettings; | ||
using Microsoft.AspNetCore.Components.Web; | ||
|
||
namespace SiemensIXBlazor.Tests.MenuSettings | ||
{ | ||
public class MenuSettingsTest : TestContextBase | ||
{ | ||
[Fact] | ||
public void MenuSettingsRendersCorrectly() | ||
{ | ||
// Arrange | ||
|
||
var cut = RenderComponent<Components.MenuSettings.MenuSettings>( | ||
|
||
("Class", "test-class"), | ||
("Style", "width: 100%"), | ||
("ActiveTabLabel", "Active Tab"), | ||
("Label", "Test Label"), | ||
("Id", "testId"), | ||
("Show", true)); | ||
|
||
// Assert | ||
cut.MarkupMatches( | ||
"<ix-menu-settings id=\"testId\" class=\"test-class\" style=\"width: 100%\" active-tab-label=\"Active Tab\" label=\"Test Label\" show=\"\"></ix-menu-settings>"); | ||
} | ||
|
||
[Fact] | ||
public async Task ClosedEventWorks() | ||
{ | ||
// Arrange | ||
var closed = false; | ||
var cut = RenderComponent<Components.MenuSettings.MenuSettings>( | ||
("Id", "menuSettings"), | ||
("ClosedEvent", EventCallback.Factory.Create(this, (MouseEventArgs args) => closed = true)) | ||
); | ||
|
||
// Act | ||
await cut.Instance.Closed(new MouseEventArgs()); | ||
|
||
// Assert | ||
Assert.True(closed); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
| ||
using Bunit; | ||
using Microsoft.AspNetCore.Components; | ||
using SiemensIXBlazor.Components; | ||
using SiemensIXBlazor.Enums.MessageBar; | ||
|
||
namespace SiemensIXBlazor.Tests; | ||
|
||
public class MessageBarTests : TestContextBase | ||
{ | ||
[Fact] | ||
public void MessageBarRendersCorrectly() | ||
{ | ||
// Arrange | ||
|
||
RenderFragment childContent = builder => | ||
{ | ||
builder.AddContent(0, "Simple Text"); | ||
}; | ||
|
||
// Act | ||
var cut = RenderComponent<MessageBar>( | ||
("Id", "testId"), | ||
("Class", "test-class"), | ||
("Style", "width: 100%"), | ||
("Dismissible", true), | ||
("Type", MessageBarType.Info), | ||
("ChildContent", childContent)); | ||
|
||
// Assert | ||
cut.MarkupMatches("<ix-message-bar id=\"testId\" class=\"test-class\" style=\"width: 100%\" dismissible=\"\" type=\"info\">Simple Text</ix-message-bar>"); | ||
} | ||
|
||
[Fact] | ||
public async Task ClosedChangeEventWorks() | ||
{ | ||
// Arrange | ||
var closed = false; | ||
var cut = RenderComponent<MessageBar>( | ||
("Id", "messageBar"), | ||
("ClosedChangeEvent", EventCallback.Factory.Create(this, () => closed = true)) | ||
); | ||
|
||
// Act | ||
cut.Instance.ClosedChange(); | ||
|
||
// Assert | ||
Assert.True(closed); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
SiemensIXBlazor.Tests/NavigationMenu/NavigationMenuAvatarItemTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Bunit; | ||
using Xunit; | ||
using SiemensIXBlazor.Components.NavigationMenu; | ||
using Microsoft.AspNetCore.Components.Web; | ||
using Microsoft.AspNetCore.Components; | ||
|
||
namespace SiemensIXBlazor.Tests.NavigationMenu | ||
{ | ||
public class NavigationMenuAvatarItemTests : TestContextBase | ||
{ | ||
[Fact] | ||
public void NavigationMenuAvatarItemRendersCorrectly() | ||
{ | ||
// Arrange | ||
var cut = RenderComponent<NavigationMenuAvatarItem>( | ||
("Id", "testId"), | ||
("Icon", "testIcon"), | ||
("Label", "Test Label"), | ||
("Class", "test-class"), | ||
("Style", "width: 100%") | ||
); | ||
|
||
// Assert | ||
// Adjust the expected markup to match your component's output | ||
cut.MarkupMatches("<ix-menu-avatar-item id=\"testId\" class=\"test-class\" style=\"width: 100%\" label=\"Test Label\" icon=\"testIcon\"></ix-menu-avatar-item>"); | ||
} | ||
|
||
[Fact] | ||
public async Task ItemClickedEventWorks() | ||
{ | ||
// Arrange | ||
var clicked = false; | ||
var cut = RenderComponent<NavigationMenuAvatarItem>( | ||
("Id", "navigationMenuAvatarItem"), | ||
("ItemClickedEvent", EventCallback.Factory.Create(this, (MouseEventArgs args) => clicked = true)) | ||
); | ||
|
||
// Act | ||
await cut.Instance.ItemClicked(new MouseEventArgs()); | ||
|
||
// Assert | ||
Assert.True(clicked); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
SiemensIXBlazor.Tests/NavigationMenu/NavigationMenuAvatarTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using Bunit; | ||
using Microsoft.AspNetCore.Components; | ||
using Xunit; | ||
using SiemensIXBlazor.Components.NavigationMenu; | ||
|
||
namespace SiemensIXBlazor.Tests.NavigationMenu | ||
{ | ||
public class NavigationMenuAvatarTests : TestContextBase | ||
{ | ||
[Fact] | ||
public void NavigationMenuAvatarRendersCorrectly() | ||
{ | ||
// Arrange | ||
var cut = RenderComponent<NavigationMenuAvatar>( | ||
("Id", "testId"), | ||
("Class", "test-class"), | ||
("Style", "width: 100%"), | ||
("Bottom", "Bottom Text"), | ||
("I18NLogout", "Logout"), | ||
("Image", "testImage"), | ||
("Initials", "TI"), | ||
("Top", "Top Text"), | ||
("ShowLogoutButton", true), | ||
("ChildContent", (RenderFragment)(builder => | ||
{ | ||
builder.OpenElement(0, "div"); | ||
builder.AddContent(1, "Test child content"); | ||
builder.CloseElement(); | ||
})) | ||
); | ||
|
||
// Assert | ||
// Adjust the expected markup to match your component's output | ||
cut.MarkupMatches("<ix-menu-avatar id=\"testId\" class=\"test-class\" style=\"width: 100%\" bottom=\"Bottom Text\" i-1-8n-logout=\"Logout\" image=\"testImage\" initials=\"TI\" top=\"Top Text\" show-logout-button=\"\"><div>Test child content</div></ix-menu-avatar>"); | ||
} | ||
[Fact] | ||
public async Task LogoutClickedEventWorks() | ||
{ | ||
// Arrange | ||
var clicked = false; | ||
var cut = RenderComponent<NavigationMenuAvatar>( | ||
("Id", "navigationMenuAvatar"), | ||
("LogoutClickedEvent", EventCallback.Factory.Create(this, () => clicked = true)) | ||
); | ||
|
||
// Act | ||
await cut.Instance.LogoutClicked(); | ||
|
||
// Assert | ||
Assert.True(clicked); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
SiemensIXBlazor.Tests/NavigationMenu/NavigationMenuCategoryTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Bunit; | ||
using Microsoft.AspNetCore.Components; | ||
using Xunit; | ||
using SiemensIXBlazor.Components.NavigationMenu; | ||
|
||
namespace SiemensIXBlazor.Tests.NavigationMenu | ||
{ | ||
public class NavigationMenuCategoryTests : TestContextBase | ||
{ | ||
[Fact] | ||
public void NavigationMenuCategoryRendersCorrectly() | ||
{ | ||
// Arrange | ||
var cut = RenderComponent<NavigationMenuCategory>( | ||
("Icon", "testIcon"), | ||
("Label", "Test Label"), | ||
("Notifications", 5), | ||
("ChildContent", (RenderFragment)(builder => | ||
{ | ||
builder.OpenElement(0, "div"); | ||
builder.AddContent(1, "Test child content"); | ||
builder.CloseElement(); | ||
})) | ||
); | ||
|
||
// Assert | ||
// Adjust the expected markup to match your component's output | ||
cut.MarkupMatches("<ix-menu-category icon=\"testIcon\" label=\"Test Label\" notifications=\"5\"><div>Test child content</div></ix-menu-category>"); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
SiemensIXBlazor.Tests/NavigationMenu/NavigationMenuItemTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Bunit; | ||
using Microsoft.AspNetCore.Components; | ||
using Xunit; | ||
using SiemensIXBlazor.Components.NavigationMenu; | ||
|
||
namespace SiemensIXBlazor.Tests.NavigationMenu | ||
{ | ||
public class NavigationMenuItemTests : TestContextBase | ||
{ | ||
[Fact] | ||
public void NavigationMenuItemRendersCorrectly() | ||
{ | ||
// Arrange | ||
var cut = RenderComponent<NavigationMenuItem>( | ||
("Active", true), | ||
("Disabled", false), | ||
("Home", true), | ||
("Icon", "testIcon"), | ||
("Notifications", 5), | ||
("TabIcon", "document"), | ||
("ChildContent", (RenderFragment)(builder => | ||
{ | ||
builder.OpenElement(0, "div"); | ||
builder.AddContent(1, "Test child content"); | ||
builder.CloseElement(); | ||
})) | ||
); | ||
|
||
// Assert | ||
// Adjust the expected markup to match your component's output | ||
cut.MarkupMatches("<ix-menu-item active=\"\" home=\"\" icon=\"testIcon\" notifications=\"5\" tab-icon=\"document\"><div>Test child content</div></ix-menu-item>"); | ||
} | ||
} | ||
} |
Oops, something went wrong.