diff --git a/.gitignore b/.gitignore
index b7a7083fb5..21437b79f1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -400,6 +400,7 @@ FodyWeavers.xsd
# Verify Test generated Files
*.received.html
+*.received.razor.html
# Specific files, typically generated by tools
*.cobertura.xml
diff --git a/tests/Core/Button/FluentButtonTests.FluentButton_Title.verified.html b/tests/Core/Button/FluentButtonRazorTests.FluentButton_Title.verified.razor.html
similarity index 100%
rename from tests/Core/Button/FluentButtonTests.FluentButton_Title.verified.html
rename to tests/Core/Button/FluentButtonRazorTests.FluentButton_Title.verified.razor.html
diff --git a/tests/Core/Button/FluentButtonRazorTests.razor b/tests/Core/Button/FluentButtonRazorTests.razor
new file mode 100644
index 0000000000..eb4b904fe9
--- /dev/null
+++ b/tests/Core/Button/FluentButtonRazorTests.razor
@@ -0,0 +1,31 @@
+@using Xunit;
+@inherits TestContext
+@code
+{
+ [Fact]
+ public void FluentButton_Title()
+ {
+ // Arrange && Act
+ var cut = Render(@My button);
+
+ // Assert
+ cut.Verify();
+ }
+
+ [Fact]
+ public void FluentButton_OnClick()
+ {
+ bool clicked = false;
+
+ // Arrange
+ var cut = Render(@
+ My button
+ );
+
+ // Act
+ cut.Find("fluent-button").Click();
+
+ // Assert
+ Assert.True(clicked);
+ }
+}
\ No newline at end of file
diff --git a/tests/Core/Button/FluentButtonTests.cs b/tests/Core/Button/FluentButtonTests.cs
index c66b2b62c2..4e677b08e3 100644
--- a/tests/Core/Button/FluentButtonTests.cs
+++ b/tests/Core/Button/FluentButtonTests.cs
@@ -5,8 +5,10 @@
namespace Microsoft.Fast.Components.FluentUI.Tests.Button;
-public class FluentButtonTests : TestBase
+public partial class FluentButtonTests : TestContext
{
+ private TestContext TestContext => new(); // TODO: To remove and to use the `RenderComponent` inherited method.
+
[Fact]
public void FluentButton_Default()
{
@@ -393,39 +395,6 @@ public void FluentButton_IconNoContent()
cut.Verify();
}
- [Fact]
- public void FluentButton_Title()
- {
- // Arrange && Act
- var cut = TestContext.RenderComponent(parameters =>
- {
- parameters.Add(p => p.Title, "My Title");
- parameters.AddChildContent("My button");
- });
-
- // Assert
- cut.Verify();
- }
-
- [Fact]
- public void FluentButton_OnClick()
- {
- bool clicked = false;
-
- // Arrange
- var cut = TestContext.RenderComponent(parameters =>
- {
- parameters.Add(p => p.OnClick, (e) => { clicked = true; });
- parameters.AddChildContent("My button");
- });
-
- // Act
- cut.Find("fluent-button").Click();
-
- // Assert
- Assert.True(clicked);
- }
-
[Fact]
public void FluentButton_OnClick_Disabled()
{
diff --git a/tests/Core/FluentAssert.cs b/tests/Core/FluentAssert.cs
index a56a4a7d85..be92e6af57 100644
--- a/tests/Core/FluentAssert.cs
+++ b/tests/Core/FluentAssert.cs
@@ -47,21 +47,27 @@ public static class FluentAssert
///
///
///
- public static void Verify(this IRenderedFragment actual,
+ public static void Verify(this IRenderedFragment? actual,
Func? received = null,
[CallerFilePath] string? filename = "",
[CallerMemberName] string? memberName = "",
string? suffix = UndefinedSuffix)
{
+ if (actual is null)
+ {
+ return;
+ }
+
// Valid?
ArgumentNullException.ThrowIfNull(filename, nameof(filename));
ArgumentNullException.ThrowIfNull(memberName, nameof(memberName));
// Files
var file = new FileInfo(filename);
+ var isRazor = file.Extension == ".razor";
var memberFullName = GetMemberFullName(memberName, suffix);
- var expectedFile = file.GetTargetFile(memberFullName, Options.VerifiedExtension);
- var receivedFile = file.GetTargetFile(memberFullName, Options.ReceivedExtension);
+ var expectedFile = file.GetTargetFile(memberFullName, isRazor ? Options.VerifiedRazorExtension : Options.VerifiedCSharpExtension);
+ var receivedFile = file.GetTargetFile(memberFullName, isRazor ? Options.ReceivedRazorExtension : Options.ReceivedCSharpExtension);
var htmlParser = actual.Services.GetRequiredService();
// Load "verified.html" file
diff --git a/tests/Core/FluentAssertOptions.cs b/tests/Core/FluentAssertOptions.cs
index c460658687..ed8d84a70b 100644
--- a/tests/Core/FluentAssertOptions.cs
+++ b/tests/Core/FluentAssertOptions.cs
@@ -7,14 +7,28 @@ namespace Microsoft.Fast.Components.FluentUI.Tests;
public class FluentAssertOptions
{
///
- /// Gets or sets default file extension used to identify an expected JSON file.
+ /// Gets or sets default file extension used to identify an expected HTML file,
+ /// generated from CS tests.
///
- public string VerifiedExtension { get; set; } = ".verified.html";
+ public string VerifiedCSharpExtension { get; set; } = ".verified.html";
///
- /// Gets or sets default file extension used to save a Card generated JSON file.
+ /// Gets or sets default file extension used to save a Card generated HTML file,
+ /// generated from CS tests.
///
- public string ReceivedExtension { get; set; } = ".received.html";
+ public string ReceivedCSharpExtension { get; set; } = ".received.html";
+
+ ///
+ /// Gets or sets default file extension used to identify an expected HTML file,
+ /// generated from RAZOR tests.
+ ///
+ public string VerifiedRazorExtension { get; set; } = ".verified.razor.html";
+
+ ///
+ /// Gets or sets default file extension used to save a Card generated JSON file,
+ /// generated from RAZOR tests.
+ ///
+ public string ReceivedRazorExtension { get; set; } = ".received.razor.html";
///
/// Scrub lines with an optional replace.
diff --git a/tests/Core/Microsoft.Fast.Components.FluentUI.Tests.csproj b/tests/Core/Microsoft.Fast.Components.FluentUI.Tests.csproj
index 9f4f6625f3..765f85be6e 100644
--- a/tests/Core/Microsoft.Fast.Components.FluentUI.Tests.csproj
+++ b/tests/Core/Microsoft.Fast.Components.FluentUI.Tests.csproj
@@ -1,4 +1,4 @@
-
+
net8.0
@@ -40,22 +40,25 @@
$([System.String]::Copy('%(FileName)').Split('.')[0])
%(ParentFile).cs
+
-
$([System.String]::Copy('%(FileName)').Split('.')[0])
%(ParentFile).cs
-
-
-
-
- FluentPersonaTests.cs
+
+
+ $([System.String]::Copy('%(FileName)').Split('.')[0])
+ %(ParentFile).razor
-
- FluentPersonaTests.cs
+
+
+
+ $([System.String]::Copy('%(FileName)').Split('.')[0])
+ %(ParentFile).razor
+
diff --git a/tests/Core/_Imports.razor b/tests/Core/_Imports.razor
new file mode 100644
index 0000000000..0f56e7c488
--- /dev/null
+++ b/tests/Core/_Imports.razor
@@ -0,0 +1,9 @@
+@using Microsoft.AspNetCore.Components.Forms
+@using Microsoft.AspNetCore.Components.Web
+@using Microsoft.JSInterop
+@using Microsoft.Extensions.DependencyInjection
+@using AngleSharp.Dom
+@using Bunit
+@using Bunit.TestDoubles
+@using Microsoft.Fast.Components.FluentUI
+@using Microsoft.Fast.Components.FluentUI.Tests
\ No newline at end of file