예제 #1
0
 /// <summary>
 /// Create a new instance of the ContextSwitcher
 /// </summary>
 /// <param name="context">The context to switch. ContextSwitcher stores the initial context.</param>
 /// <param name="path">The path to switc to</param>
 public ContextSwitcher(Context context, string path)
 {
   if (!string.IsNullOrEmpty(path))
   {
     _active = true;
     StoreContext(context);
     _result = context.SetContext(path);
   }
   else
     _result = new CommandResult(CommandStatus.Success, "ContextSwitcher not active");
 }
예제 #2
0
    public void SetContext_Relative()
    {
      var context = new Revolver.Core.Context();
      context.CurrentItem = _testTreeRoot;

      var result = context.SetContext("Sycorax");

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(context.CurrentDatabase.Name, Is.EqualTo("web"));
      Assert.That(context.CurrentItem.ID, Is.EqualTo(_testTreeRoot.Axes.GetChild("Sycorax").ID));
      Assert.That(context.CurrentLanguage.Name, Is.EqualTo("en"));
    }
예제 #3
0
    public void SetContext_NumberedChild()
    {
      var startItem = _testTreeRoot.Axes.SelectSingleItem("Umbriel");

      var context = new Revolver.Core.Context();
      context.CurrentItem = startItem;

      var expectedItem = _testTreeRoot.Axes.SelectSingleItem("Umbriel/*[@title='Skoll 1']");

      var result = context.SetContext("skoll[1]");

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(context.CurrentDatabase.Name, Is.EqualTo("web"));
      Assert.That(context.CurrentItem.ID, Is.EqualTo(expectedItem.ID));
      Assert.That(context.CurrentLanguage.Name, Is.EqualTo("en"));
    }
예제 #4
0
    public void SetContext_BadVersionNumber()
    {
      var context = new Revolver.Core.Context();
      context.CurrentItem = _testTreeRoot;

      var item = _testTreeRoot.Axes.GetChild("Sycorax");

      var result = context.SetContext(item.Paths.FullPath + "::&", null);

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Failure));
      Assert.That(context.CurrentDatabase.Name, Is.EqualTo("web"));
      Assert.That(context.CurrentItem.ID, Is.EqualTo(_testTreeRoot.ID));
      Assert.That(context.CurrentLanguage.Name, Is.EqualTo("en"));
    }
예제 #5
0
    public void SetContext_NumberedChildTooHigh()
    {
      var startItem = _testTreeRoot.Axes.SelectSingleItem("Umbriel");

      var context = new Revolver.Core.Context();
      context.CurrentItem = startItem;

      var result = context.SetContext("skoll[5]");

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Failure));
      Assert.That(context.CurrentDatabase.Name, Is.EqualTo("web"));
      Assert.That(context.CurrentItem.ID, Is.EqualTo(startItem.ID));
      Assert.That(context.CurrentLanguage.Name, Is.EqualTo("en"));
    }
예제 #6
0
파일: Util.cs 프로젝트: KerwinMa/revolver
 public static CommandResult SetContext(Context context, string path, string dbName = null, Language language = null, int? versionNumber = null)
 {
   return context.SetContext(path, dbName, language, versionNumber);
 }