2022-10-30 15:13:39 +00:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
2022-10-30 15:13:18 +00:00
|
|
|
namespace LeedsBeerQuest.API.Tests.TestHelpers;
|
|
|
|
|
2022-10-30 15:13:39 +00:00
|
|
|
public static class ControllerTestHelper
|
2022-10-30 15:13:18 +00:00
|
|
|
{
|
2022-10-30 15:13:39 +00:00
|
|
|
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!;
|
|
|
|
}
|
2022-10-30 15:13:18 +00:00
|
|
|
}
|