public DemoContent ( ) : System.Web.Mvc.ActionResult | ||
return | System.Web.Mvc.ActionResult |
public ActionResult DemoContent()
{
var item = RenderingContext.Current?.Rendering?.Item ?? RenderingContext.Current?.ContextItem;
if (item == null || !item.IsDerived(Templates.DemoContent.ID))
{
throw new InvalidDataSourceItemException($"Item should be not null and derived from {nameof(Templates.DemoContent)} {Templates.DemoContent.ID} template");
}
return this.View("DemoContent", new DemoContent(item));
}
public void DemoContent_RenderingContextItemInitialized_ShouldReturnDemoContentView(Db db,IContactProfileProvider contact, IProfileProvider profile, ITracker tracker) { //arrange var itemID = ID.NewID; db.Add(new DbItem("ctx",itemID, Templates.DemoContent.ID)); var controller = new DemoController(contact, profile); var context = new RenderingContext(); context.ContextItem = db.GetItem(itemID); ContextService.Get().Push(context); using (new TrackerSwitcher(tracker)) { controller.DemoContent().As<ViewResult>().Model.Should().BeOfType<DemoContent>(); } }