Events-MVC (example with htmx)
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user