Add test helper for controller result values
This commit is contained in:
parent
d82d1b0dab
commit
115623ec4d
@ -1,6 +1,18 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace LeedsBeerQuest.API.Tests.TestHelpers;
|
||||
|
||||
public class ControllerTestHelper
|
||||
public static class ControllerTestHelper
|
||||
{
|
||||
|
||||
public static T ActionResultToOkResultValue<T>(IActionResult actionResult) where T : class
|
||||
{
|
||||
var okResult = actionResult as OkObjectResult;
|
||||
Assert.NotNull(okResult);
|
||||
|
||||
var resultValue = okResult!.Value as T;
|
||||
Assert.NotNull(resultValue);
|
||||
|
||||
return resultValue!;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user