Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ root = true
[*]
indent_style = tab
indent_size = tab
tab_size = 4
tab_width = 4
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
Expand Down
4 changes: 1 addition & 3 deletions docs/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ root = true

[*]
indent_style = space
tab_size = 2
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
Expand All @@ -11,8 +11,6 @@ insert_final_newline = false
trim_trailing_whitespace = false

[*.{cs,razor}]
tab_size = 2
indent_style = space
dotnet_diagnostic.BL0001.severity = none
dotnet_diagnostic.BL0002.severity = none
dotnet_diagnostic.BL0003.severity = none
Expand Down
16 changes: 8 additions & 8 deletions docs/samples/tests/mstest/BunitTestContext.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
namespace Bunit.Docs.Samples;

using Microsoft.VisualStudio.TestTools.UnitTesting;
using Bunit;

namespace Bunit.Docs.Samples
public abstract class BunitTestContext : TestContextWrapper
{
public abstract class BunitTestContext : TestContextWrapper
{
[TestInitialize]
public void Setup() => TestContext = new Bunit.TestContext();
[TestInitialize]
public void Setup() => TestContext = new Bunit.TestContext();

[TestCleanup]
public void TearDown() => TestContext?.Dispose();
}
[TestCleanup]
public void TearDown() => TestContext?.Dispose();
}
19 changes: 0 additions & 19 deletions docs/samples/tests/mstest/HelloWorldImplicitContextTest.cs

This file was deleted.

8 changes: 3 additions & 5 deletions docs/samples/tests/mstest/HelloWorldRazorTest.razor
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
@attribute [TestClass]
@code
@inherits BunitTestContext
@code
{
[TestMethod]
public void HelloWorldComponentRendersCorrectly()
{
// Arrange
using var ctx = new Bunit.TestContext();

// Act
var cut = ctx.Render(@<HelloWorld/>);
var cut = Render(@<HelloWorld/>);

// Assert
cut.MarkupMatches(@<h1>Hello world from Blazor</h1>);
Expand Down
26 changes: 11 additions & 15 deletions docs/samples/tests/mstest/HelloWorldTest.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
using Bunit;
namespace Bunit.Docs.Samples;

using Microsoft.VisualStudio.TestTools.UnitTesting;
using Bunit;

namespace Bunit.Docs.Samples
[TestClass]
public class HelloWorldTest : BunitTestContext
{
[TestClass]
public class HelloWorldTest
[TestMethod]
public void HelloWorldComponentRendersCorrectly()
{
[TestMethod]
public void HelloWorldComponentRendersCorrectly()
{
// Arrange
using var ctx = new Bunit.TestContext();

// Act
var cut = ctx.RenderComponent<HelloWorld>();
// Act
var cut = RenderComponent<HelloWorld>();

// Assert
cut.MarkupMatches("<h1>Hello world from Blazor</h1>");
}
// Assert
cut.MarkupMatches("<h1>Hello world from Blazor</h1>");
}
}
15 changes: 7 additions & 8 deletions docs/samples/tests/nunit/BunitTestContext.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
namespace Bunit.Docs.Samples;

using Bunit;
using NUnit.Framework;

namespace Bunit.Docs.Samples
public abstract class BunitTestContext : TestContextWrapper
{
public abstract class BunitTestContext : TestContextWrapper
{
[SetUp]
public void Setup() => TestContext = new Bunit.TestContext();
[SetUp]
public void Setup() => TestContext = new Bunit.TestContext();

[TearDown]
public void TearDown() => TestContext?.Dispose();
}
[TearDown]
public void TearDown() => TestContext?.Dispose();
}
13 changes: 0 additions & 13 deletions docs/samples/tests/nunit/HelloWorldImplicitContextRazorTest.razor

This file was deleted.

18 changes: 0 additions & 18 deletions docs/samples/tests/nunit/HelloWorldImplicitContextTest.cs

This file was deleted.

6 changes: 2 additions & 4 deletions docs/samples/tests/nunit/HelloWorldRazorTest.razor
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
@inherits BunitTestContext
@code
{
[Test]
public void HelloWorldComponentRendersCorrectly()
{
// Arrange
using var ctx = new Bunit.TestContext();

// Act
var cut = ctx.Render(@<HelloWorld />);
var cut = Render(@<HelloWorld />);

// Assert
cut.MarkupMatches(@<h1>Hello world from Blazor</h1>);
Expand Down
18 changes: 7 additions & 11 deletions docs/samples/tests/nunit/HelloWorldTest.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
namespace Bunit.Docs.Samples;

using Bunit;
using NUnit.Framework;

namespace Bunit.Docs.Samples
public class HelloWorldTest : BunitTestContext
{
public class HelloWorldTest
{
[Test]
public void HelloWorldComponentRendersCorrectly()
{
// Arrange
using var ctx = new Bunit.TestContext();

// Act
var cut = ctx.RenderComponent<HelloWorld>();
// Act
var cut = RenderComponent<HelloWorld>();

// Assert
cut.MarkupMatches("<h1>Hello world from Blazor</h1>");
// Assert
cut.MarkupMatches("<h1>Hello world from Blazor</h1>");
}
}
}
10 changes: 5 additions & 5 deletions docs/samples/tests/razor/CascadingParams1Test.razor
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@inherits TestContext

@code
{
[Fact]
public void Test()
{
using var ctx = new TestContext();

var isDarkTheme = true;

var cut = ctx.Render(@<CascadingValue Value="isDarkTheme">
<CascadingParams />
</CascadingValue>);
var cut = Render(@<CascadingValue Value="isDarkTheme">
<CascadingParams />
</CascadingValue>);
}
}
10 changes: 5 additions & 5 deletions docs/samples/tests/razor/CascadingParams2Test.razor
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@inherits TestContext

@code
{
[Fact]
public void Test()
{
using var ctx = new TestContext();

var cut = ctx.Render(@<CascadingValue Name="LoggedInUser" Value=@("Name of User")>
<CascadingParams />
</CascadingValue>);
var cut = Render(@<CascadingValue Name="LoggedInUser" Value=@("Name of User")>
<CascadingParams />
</CascadingValue>);
}
}
18 changes: 9 additions & 9 deletions docs/samples/tests/razor/CascadingParams3Test.razor
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
@inherits TestContext

@code
{
[Fact]
public void Test()
{
using var ctx = new TestContext();

var isDarkTheme = true;

var cut = ctx.Render(@<CascadingValue Name="LoggedInUser" Value=@("Name of User")>
<CascadingValue Name="LoggedInEmail" Value=@("user@example.com")>
<CascadingValue Value="isDarkTheme">
<CascadingParams />
</CascadingValue>
</CascadingValue>
</CascadingValue>);
var cut = Render(@<CascadingValue Name="LoggedInUser" Value=@("Name of User")>
<CascadingValue Name="LoggedInEmail" Value=@("user@example.com")>
<CascadingValue Value="isDarkTheme">
<CascadingParams />
</CascadingValue>
</CascadingValue>
</CascadingValue>);
}
}
10 changes: 5 additions & 5 deletions docs/samples/tests/razor/ChildContentParams1Test.razor
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@inherits TestContext

@code
{
[Fact]
public void Test()
{
using var ctx = new TestContext();

var cut = ctx.Render(@<ChildContentParams>
<h1>Hello World</h1>
</ChildContentParams>);
var cut = Render(@<ChildContentParams>
<h1>Hello World</h1>
</ChildContentParams>);
}
}
10 changes: 5 additions & 5 deletions docs/samples/tests/razor/ChildContentParams2Test.razor
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@inherits TestContext

@code
{
[Fact]
public void Test()
{
using var ctx = new TestContext();

var cut = ctx.Render(@<ChildContentParams>
<Counter />
</ChildContentParams>);
var cut = Render(@<ChildContentParams>
<Counter />
</ChildContentParams>);
}
}
14 changes: 7 additions & 7 deletions docs/samples/tests/razor/ChildContentParams3Test.razor
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@inherits TestContext

@code
{
[Fact]
public void Test()
{
using var ctx = new TestContext();

var cut = ctx.Render(@<ChildContentParams>
<Alert Heading="Alert heading" Type=@AlertType.Warning>
<p>Hello World</p>
</Alert>
</ChildContentParams>);
var cut = Render(@<ChildContentParams>
<Alert Heading="Alert heading" Type=@AlertType.Warning>
<p>Hello World</p>
</Alert>
</ChildContentParams>);
}
}
16 changes: 8 additions & 8 deletions docs/samples/tests/razor/ChildContentParams4Test.razor
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
@inherits TestContext

@code
{
[Fact]
public void Test()
{
using var ctx = new TestContext();

var cut = ctx.Render(@<ChildContentParams>
<h1>Below you will find a most interesting alert!</h1>
<Alert Heading="Alert heading" Type=@AlertType.Warning>
<p>Hello World</p>
</Alert>
</ChildContentParams>);
var cut = Render(@<ChildContentParams>
<h1>Below you will find a most interesting alert!</h1>
<Alert Heading="Alert heading" Type=@AlertType.Warning>
<p>Hello World</p>
</Alert>
</ChildContentParams>);
}
}
5 changes: 3 additions & 2 deletions docs/samples/tests/razor/ClickMeTest.razor
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
@inherits TestContext

@code
{
[Fact]
public void Test()
{
// Arrange
using var ctx = new TestContext();
var cut = ctx.Render(@<ClickMe />);
var cut = Render(@<ClickMe />);
var buttonElement = cut.Find("button");

// Act
Expand Down
Loading