Inheritance: SitecoreController
 public void VisitDetails_TrackerInteractionNotInitialized_ShouldReturnNull(IContactProfileProvider contact, IProfileProvider profile, ITracker tracker)
 {
   //arrange
   var controller = new DemoController(contact, profile);
   using (new TrackerSwitcher(tracker))
   {
     controller.VisitDetails().Should().Be(null);
   }
 }
 public void ContactDetails_ContactInitialized_ShouldReturnContactInformation(IContactProfileProvider contact, IProfileProvider profile, ITracker tracker)
 {
   //arrange
   var controller = new DemoController(contact, profile);
   using (new TrackerSwitcher(tracker))
   {
     controller.ContactDetails().As<ViewResult>().Model.Should().BeOfType<ContactInformation>();
   }
 }
 public void ContactDetails_ContactNotInitialized_ShouldReturnNull(IContactProfileProvider contact, IProfileProvider profile, ITracker tracker)
 {
   tracker.Contact.Returns((Contact)null);
   //arrange
   var controller = new DemoController(contact, profile);
   using (new TrackerSwitcher(tracker))
   {
     controller.ContactDetails().Should().BeNull();
   }
 }
 public void VisitDetails_TrackerInitialized_ShouldReturnVisitInformation(IContactProfileProvider contact, IProfileProvider profile, ITracker tracker, CurrentInteraction interaction)
 {
   tracker.Interaction.Returns(interaction);
   //arrange
   var controller = new DemoController(contact, profile);
   using (new TrackerSwitcher(tracker))
   {
     controller.VisitDetails().As<ViewResult>().Model.Should().BeOfType<VisitInformation>();
   }
 }
    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>();
      }
    }
    public void DemoContent_RenderingContextItemNotInitialized_ShouldThrowException(IContactProfileProvider contact, IProfileProvider profile, ITracker tracker)
    {
      //arrange

      var controller = new DemoController(contact, profile);
      var context = new RenderingContext();
      ContextService.Get().Push(context);
      using (new TrackerSwitcher(tracker))
      {
        controller.Invoking(x => x.DemoContent()).ShouldThrow<InvalidDataSourceItemException>();
      }
    }
 public void EndVisit_ShouldEndSession(IContactProfileProvider contact, IProfileProvider profile, [Substitute]ControllerContext ctx)
 {
   //arrange
   var controller = new DemoController(contact, profile);
   controller.ControllerContext = ctx;
   controller.EndVisit();
   ctx.HttpContext.Session.Received(1).Abandon();
 }
 public void EndVisit_ShouldReturnRedirectToRoot(IContactProfileProvider contact, IProfileProvider profile, [Substitute]ControllerContext ctx)
 {
   //arrange
   var controller = new DemoController(contact, profile);
   controller.ControllerContext = ctx;
   controller.EndVisit().As<RedirectResult>().Url.Should().Be("/");
 }
 public void DemoContent_RenderingContextNotDerivedFromSpecificTemplate_ShouldThrowException([Content]Item ctxItem, IContactProfileProvider contact, IProfileProvider profile, ITracker tracker)
 {
   //arrange
   var controller = new DemoController(contact, profile);
   var context = new RenderingContext();
   context.ContextItem = ctxItem;
   ContextService.Get().Push(context);
   using (new TrackerSwitcher(tracker))
   {
     controller.Invoking(x => x.DemoContent()).ShouldThrow<InvalidDataSourceItemException>();
   }
 }