public void GetPropertiesShouldNotThrowExceptionForPocoController() { MyMvc .IsUsingDefaultConfiguration() .WithServices(services => { services.AddHttpContextAccessor(); }); var helper = ViewFeaturesControllerPropertyHelper.GetViewFeatureProperties <FullPocoController>(); var controllerContext = new ControllerContext(); var controller = new FullPocoController { CustomControllerContext = controllerContext }; Assert.NotNull(controller.CustomControllerContext); Assert.Same(controllerContext, controller.CustomControllerContext); var gotControllerContext = helper.ControllerContextGetter(controller); Assert.NotNull(gotControllerContext); Assert.Same(gotControllerContext, controller.CustomControllerContext); var actionContext = new ActionContext(); controller.CustomActionContext = actionContext; Assert.NotNull(controller.CustomActionContext); Assert.Same(actionContext, controller.CustomActionContext); var gotActionContext = helper.ActionContextGetter(controller); Assert.NotNull(gotActionContext); Assert.Same(gotActionContext, controller.CustomActionContext); var gotViewData = helper.ViewDataGetter(controller); Assert.NotNull(gotViewData); Assert.Same(gotViewData, controller.CustomViewData); var gotTempData = helper.TempDataGetter(controller); Assert.NotNull(gotTempData); Assert.Same(gotTempData, controller.CustomTempData); MyMvc.IsUsingDefaultConfiguration(); }
public void GetPropertiesShouldNotThrowExceptionForPocoController() { MyMvc .IsUsingDefaultConfiguration() .WithServices(services => { services.AddHttpContextAccessor(); }); var helper = ViewFeaturesControllerPropertyHelper.GetViewFeatureProperties<FullPocoController>(); var controllerContext = new ControllerContext(); var controller = new FullPocoController { CustomControllerContext = controllerContext }; Assert.NotNull(controller.CustomControllerContext); Assert.Same(controllerContext, controller.CustomControllerContext); var gotControllerContext = helper.ControllerContextGetter(controller); Assert.NotNull(gotControllerContext); Assert.Same(gotControllerContext, controller.CustomControllerContext); var actionContext = new ActionContext(); controller.CustomActionContext = actionContext; Assert.NotNull(controller.CustomActionContext); Assert.Same(actionContext, controller.CustomActionContext); var gotActionContext = helper.ActionContextGetter(controller); Assert.NotNull(gotActionContext); Assert.Same(gotActionContext, controller.CustomActionContext); var gotViewData = helper.ViewDataGetter(controller); Assert.NotNull(gotViewData); Assert.Same(gotViewData, controller.CustomViewData); var gotTempData = helper.TempDataGetter(controller); Assert.NotNull(gotTempData); Assert.Same(gotTempData, controller.CustomTempData); MyMvc.IsUsingDefaultConfiguration(); }
public void GetPropertiesShouldNotThrowExceptionForPocoController() { MyApplication .StartsFrom <DefaultStartup>() .WithServices(services => { services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); }); var helper = ControllerPropertyHelper.GetProperties <FullPocoController>(); var controllerContext = new ControllerContext(); var controller = new FullPocoController { CustomControllerContext = controllerContext }; Assert.NotNull(controller.CustomControllerContext); Assert.Same(controllerContext, controller.CustomControllerContext); var gotControllerContext = helper.ControllerContextGetter(controller); Assert.NotNull(gotControllerContext); Assert.Same(gotControllerContext, controller.CustomControllerContext); var actionContext = new ActionContext(); controller.CustomActionContext = actionContext; Assert.NotNull(controller.CustomActionContext); Assert.Same(actionContext, controller.CustomActionContext); var gotActionContext = helper.ActionContextGetter(controller); Assert.NotNull(gotActionContext); Assert.Same(gotActionContext, controller.CustomActionContext); MyApplication.StartsFrom <DefaultStartup>(); }
public void GetPropertiesShouldNotThrowExceptionForPocoController() { MyApplication .StartsFrom<DefaultStartup>() .WithServices(services => { services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); }); var helper = ControllerPropertyHelper.GetProperties<FullPocoController>(); var controllerContext = new ControllerContext(); var controller = new FullPocoController { CustomControllerContext = controllerContext }; Assert.NotNull(controller.CustomControllerContext); Assert.Same(controllerContext, controller.CustomControllerContext); var gotControllerContext = helper.ControllerContextGetter(controller); Assert.NotNull(gotControllerContext); Assert.Same(gotControllerContext, controller.CustomControllerContext); var actionContext = new ActionContext(); controller.CustomActionContext = actionContext; Assert.NotNull(controller.CustomActionContext); Assert.Same(actionContext, controller.CustomActionContext); var gotActionContext = helper.ActionContextGetter(controller); Assert.NotNull(gotActionContext); Assert.Same(gotActionContext, controller.CustomActionContext); MyApplication.StartsFrom<DefaultStartup>(); }
public void GetPropertiesShouldNotThrowExceptionForPocoController() { MyApplication .StartsFrom<DefaultStartup>() .WithServices(services => { services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>(); }); var helper = TempDataPropertyHelper.GetTempDataProperties<FullPocoController>(); var controllerContext = new ControllerContext(); var controller = new FullPocoController { CustomControllerContext = controllerContext }; var gotTempData = helper.TempDataGetter(controller); Assert.NotNull(gotTempData); Assert.Same(gotTempData, controller.CustomTempData); MyApplication.StartsFrom<DefaultStartup>(); }
public void GetPropertiesShouldNotThrowExceptionForPocoController() { MyApplication .StartsFrom <DefaultStartup>() .WithServices(services => { services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>(); }); var helper = ViewDataPropertyHelper.GetViewDataProperties <FullPocoController>(); var controllerContext = new ControllerContext(); var controller = new FullPocoController { CustomControllerContext = controllerContext }; var gotViewData = helper.ViewDataGetter(controller); Assert.NotNull(gotViewData); Assert.Same(gotViewData, controller.CustomViewData); MyApplication.StartsFrom <DefaultStartup>(); }