Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
apfohl committed Jan 4, 2024
1 parent 43ebf1d commit d953063
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions HotwiredBooks/Extensions/FunctionalExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ public static ErrorOr<StringValues> JustGetValue(this IFormCollection collection
? ErrorOrFactory.From(value)
: ErrorOr<StringValues>.From([Error.NotFound()]);

public static T OrElse<T>(this ErrorOr<T> maybe, T orElse) =>
maybe.Match(value => value, _ => orElse);
public static T OrElse<T>(this ErrorOr<T> errorOr, T orElse) =>
errorOr.Match(value => value, _ => orElse);

public static T OrElse<T>(this ErrorOr<T> maybe, Func<T> orElse) =>
maybe.Match(value => value, _ => orElse());
public static T OrElse<T>(this ErrorOr<T> errorOr, Func<T> orElse) =>
errorOr.Match(value => value, _ => orElse());

public static async Task<T> OrElse<T>(this Task<ErrorOr<T>> maybe, Func<T> orElse) =>
(await maybe).Match(value => value, _ => orElse());
public static async Task<T> OrElse<T>(this Task<ErrorOr<T>> errorOr, Func<T> orElse) =>
(await errorOr).Match(value => value, _ => orElse());

public static async Task<T> OrElse<T>(this Task<ErrorOr<T>> maybe, T orElse) =>
(await maybe).Match(value => value, _ => orElse);
public static async Task<T> OrElse<T>(this Task<ErrorOr<T>> errorOr, T orElse) =>
(await errorOr).Match(value => value, _ => orElse);
}
24 changes: 12 additions & 12 deletions HotwiredBooksTests/HtmlHelperExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ private static IEnumerable<object[]> DomIdTestCases
{
get
{
yield return new object[] { typeof(BookWithId), null, "new_book_with_id" };
yield return new object[] { new BookWithId(Id), null, $"book_with_id_{Id}" };
yield return new object[] { new BookWithoutId(), null, "new_book_without_id" };
yield return new object[] { typeof(BookWithId), "header", "header_book_with_id" };
yield return new object[] { new BookWithId(Id), "header", $"header_book_with_id_{Id}" };
yield return new object[] { new BookWithoutId(), "header", "header_book_without_id" };
yield return [typeof(BookWithId), null, "new_book_with_id"];
yield return [new BookWithId(Id), null, $"book_with_id_{Id}"];
yield return [new BookWithoutId(), null, "new_book_without_id"];
yield return [typeof(BookWithId), "header", "header_book_with_id"];
yield return [new BookWithId(Id), "header", $"header_book_with_id_{Id}"];
yield return [new BookWithoutId(), "header", "header_book_without_id"];
}
}

Expand All @@ -36,12 +36,12 @@ private static IEnumerable<object[]> DomClassTestCases
{
get
{
yield return new object[] { typeof(BookWithId), null, "book_with_id" };
yield return new object[] { new BookWithId(Id), null, "book_with_id" };
yield return new object[] { new BookWithoutId(), null, "book_without_id" };
yield return new object[] { typeof(BookWithId), "header", "header_book_with_id" };
yield return new object[] { new BookWithId(Id), "header", "header_book_with_id" };
yield return new object[] { new BookWithoutId(), "header", "header_book_without_id" };
yield return [typeof(BookWithId), null, "book_with_id"];
yield return [new BookWithId(Id), null, "book_with_id"];
yield return [new BookWithoutId(), null, "book_without_id"];
yield return [typeof(BookWithId), "header", "header_book_with_id"];
yield return [new BookWithId(Id), "header", "header_book_with_id"];
yield return [new BookWithoutId(), "header", "header_book_without_id"];
}
}

Expand Down

0 comments on commit d953063

Please sign in to comment.