20 lines
594 B
C#
20 lines
594 B
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
|
|
|
namespace Events.Tests.UnitTests.Infrastructure;
|
|
|
|
internal static class ControllerTestExtensions
|
|
{
|
|
public static T WithTempData<T>(this T controller) where T : Controller
|
|
{
|
|
var httpContext = new DefaultHttpContext();
|
|
controller.ControllerContext = new ControllerContext
|
|
{
|
|
HttpContext = httpContext
|
|
};
|
|
controller.TempData = new TempDataDictionary(httpContext, new TestTempDataProvider());
|
|
return controller;
|
|
}
|
|
}
|