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
19 changes: 18 additions & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,21 @@ This document describes the changes that need to be made to migrate from bUnit 1
## Removal of `GetChangesSinceFirstRender` and `GetChangesSinceLastRender` methods
The `GetChangesSinceFirstRender` and `GetChangesSinceLastRender` methods have been removed from `IRenderedComponent<TComponent>`. There is no one-to-one replacement for these methods, but the general idea is to select the HTML in question via `Find` and assert against that.

Alternatively, the `IRenderFragment` still offers the `OnMarkupUpdated` event, which can be used to assert against the markup after a render.
Alternatively, the `IRenderFragment` still offers the `OnMarkupUpdated` event, which can be used to assert against the markup after a render.

## Removal of `IsNullOrEmpty` extension method on `IEnumerable<T>` and `CreateLogger` on `IserviceProvider`
The `IsNullOrEmpty` extension method on `IEnumerable<T>` has been removed, as well as the `CreateLogger` extension method on `IServiceProvider`. These extension methods are pretty common and conflict with other libraries. These methods can be recreated like this:

```csharp
public static class Extensions
{
public static bool IsNullOrEmpty<T>(this IEnumerable<T> enumerable)
=> enumerable == null || !enumerable.Any();

public static ILogger<T> CreateLogger<T>(this IServiceProvider serviceProvider)
{
var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>() ?? NullLoggerFactory.Instance;
return loggerFactory.CreateLogger<T>();
}
}
```
2 changes: 1 addition & 1 deletion src/bunit.core/Extensions/LoggerHelperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Bunit.Extensions;
/// <summary>
/// Helper extension methods for getting a logger.
/// </summary>
public static class LoggerHelperExtensions
internal static class LoggerHelperExtensions
{
/// <summary>
/// Creates a logger from the <see cref="ILoggerFactory"/> registered in the <see cref="IServiceProvider"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ namespace Bunit.Extensions;
/// <summary>
/// Helper methods for working with <see cref="IEnumerable{T}"/>.
/// </summary>
public static class EnumerableExtensions
internal static class EnumerableExtensions
{
/// <summary>
/// Returns true if the numerable is null or empty.
/// Returns true if the enumerable is null or empty.
/// </summary>
public static bool IsNullOrEmpty<T>([NotNullWhen(false)] this IEnumerable<T>? enumerable)
{
Expand Down