mirror of
https://github.com/bitwarden/server.git
synced 2025-05-05 11:42:22 -05:00
[PM-15621] Clean up
This commit is contained in:
parent
8762fe10b3
commit
b9bc4e968c
@ -1,36 +0,0 @@
|
||||
using Bit.Core.Models.Commands;
|
||||
|
||||
namespace Bit.Core.Validators;
|
||||
|
||||
public static class CommandResultValidator
|
||||
{
|
||||
public static CommandResult ExecuteValidators(Func<CommandResult>[] validators)
|
||||
{
|
||||
foreach (var validator in validators)
|
||||
{
|
||||
var result = validator();
|
||||
|
||||
if (result is not Success)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return new Success();
|
||||
}
|
||||
|
||||
public static async Task<CommandResult> ExecuteValidatorAsync(Func<Task<CommandResult>>[] validators)
|
||||
{
|
||||
foreach (var validator in validators)
|
||||
{
|
||||
var result = await validator();
|
||||
|
||||
if (result is not Success)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return new Success();
|
||||
}
|
||||
}
|
@ -38,7 +38,7 @@ public class CommandResultExtensionTests
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(WithGenericTypeTestCases))]
|
||||
public void MapToActionResult_WithGenericType_ShouldMapToHttpResponse(CommandResult<Cipher> input, ObjectResult expected)
|
||||
public void MapToActionResultWithErrorMessages_WithGenericType_ShouldMapToHttpResponse(CommandResult<Cipher> input, ObjectResult expected)
|
||||
{
|
||||
var result = input.MapToActionResultWithErrorMessages();
|
||||
|
||||
@ -47,7 +47,7 @@ public class CommandResultExtensionTests
|
||||
|
||||
|
||||
[Fact]
|
||||
public void MapToActionResult_WithGenericType_ShouldThrowExceptionForUnhandledCommandResult()
|
||||
public void MapToActionResultWithErrorMessages_WithGenericType_ShouldThrowExceptionForUnhandledCommandResult()
|
||||
{
|
||||
var result = new NotImplementedCommandResult();
|
||||
|
||||
@ -80,7 +80,7 @@ public class CommandResultExtensionTests
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(TestCases))]
|
||||
public void MapToActionResult_ShouldMapToHttpResponse(CommandResult input, ObjectResult expected)
|
||||
public void MapToActionResultWithErrorMessages_ShouldMapToHttpResponse(CommandResult input, ObjectResult expected)
|
||||
{
|
||||
var result = input.MapToActionResult();
|
||||
|
||||
@ -88,7 +88,7 @@ public class CommandResultExtensionTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MapToActionResult_ShouldThrowExceptionForUnhandledCommandResult()
|
||||
public void MapToActionResultWithErrorMessages_ShouldThrowExceptionForUnhandledCommandResult()
|
||||
{
|
||||
var result = new NotImplementedCommandResult<Cipher>();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user