x-lab-lbq-technical-test/backend/LeedsBeerQuest.API/LeedsBeerQuest.API.Tests/TestHelpers/ControllerTestHelper.cs

18 lines
461 B
C#
Raw Normal View History

using Microsoft.AspNetCore.Mvc;
using NUnit.Framework;
namespace LeedsBeerQuest.API.Tests.TestHelpers;
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!;
}
}