Ejemplo n.º 1
0
    public void NoCommand()
    {
      var ctx = new Mod.Context();
      var handler = new Mod.CommandHandler(ctx, new TextOutputFormatter());
      var result = handler.Execute("");

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(result.Message, Is.Empty);
    }
Ejemplo n.º 2
0
    public void CommandSingleNumberedParameter()
    {
      var ctx = new Mod.Context();
      ctx.CurrentItem = _testContent;
      var handler = new Mod.CommandHandler(ctx, new TextOutputFormatter());
      var result = handler.Execute("cd luna");

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(ctx.CurrentItem.ID, Is.EqualTo(_testContent.Axes.GetChild("Luna").ID));
    }
Ejemplo n.º 3
0
    public void CommandMultipleNumberedParameters()
    {
      var ctx = new Mod.Context();
      ctx.CurrentItem = _testContent;
      var handler = new Mod.CommandHandler(ctx, new TextOutputFormatter());
      var result = handler.Execute("find pwd luna");

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(result.Message, Contains.Substring("Carme"));
      Assert.That(result.Message, Contains.Substring("Ganymede"));
      Assert.That(result.Message, Contains.Substring("Metis"));
    }
Ejemplo n.º 4
0
    public void CommandSingleNamedParameter()
    {
      var ctx = new Mod.Context();
      ctx.CurrentItem = _testContent;
      var handler = new Mod.CommandHandler(ctx, new TextOutputFormatter());
      var result = handler.Execute("ls -r os");

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(result.Message, Is.Not.Contains("Luna"));
      Assert.That(result.Message, Contains.Substring("Deimos"));
      Assert.That(result.Message, Contains.Substring("phobos"));
      Assert.That(result.Message, Contains.Substring("Adrastea Phobos"));
    }
Ejemplo n.º 5
0
    public void CommandMixedParameterTypes()
    {
      var deimosId = _testContent.Axes.GetChild("Deimos").ID.ToString();
      var phobosId = _testContent.Axes.GetChild("phobos").ID.ToString();

      var ctx = new Mod.Context();
      ctx.CurrentItem = _testContent;
      var handler = new Mod.CommandHandler(ctx, new TextOutputFormatter());
      var result = handler.Execute(string.Format("find -i {0}|{1} -a name phobos -ns (ga -a id)", deimosId, phobosId));

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(result.Message, Is.EqualTo(phobosId));
    }
Ejemplo n.º 6
0
    public void AddAliasWithParameters()
    {
      var ctx = new Mod.Context();
      ctx.CurrentItem = _testContent;
      var handler = new Mod.CommandHandler(ctx, new TextOutputFormatter());

      var result = handler.AddCommandAlias("aa", "ls", "-a", "-d");
      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));

      // Verify the alias was added
      var exResult = handler.Execute("aa");
      Assert.That(exResult.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(exResult.Message, Contains.Substring("  phobos\r\n+ Luna\r\n  Deimos\r\n  Adrastea Phobos"));
    }
Ejemplo n.º 7
0
    public void EscapedParameterDelimiter()
    {
      var ctx = new Mod.Context();
      ctx.CurrentItem = _testContent;
      var handler = new Mod.CommandHandler(ctx, new TextOutputFormatter());
      var result = handler.Execute("echo lorem \\(ipsum dolor\\)");

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(result.Message, Is.EqualTo("lorem (ipsum dolor)"));
    }
Ejemplo n.º 8
0
    public void MultipleCommandChaining()
    {
      var ctx = new Mod.Context();
      ctx.CurrentItem = _testContent;
      var handler = new Mod.CommandHandler(ctx, new TextOutputFormatter());
      var result = handler.Execute("ga -a name > replace $~$ B c -c > split -s h $~$ (echo $current$)");

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success), result.Message);
      Assert.That(result.Message, Contains.Substring("ceb"));
      Assert.That(result.Message, Contains.Substring("ionn"));
    }
Ejemplo n.º 9
0
    public void CommandChaining()
    {
      var ctx = new Mod.Context();
      ctx.CurrentItem = _testContent;
      var handler = new Mod.CommandHandler(ctx, new TextOutputFormatter());
      var result = handler.Execute("ga -a name > replace $~$ B c -c");

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success), result.Message);
      Assert.That(result.Message, Is.EqualTo("cebhionn"));
    }
Ejemplo n.º 10
0
    public void MultipleSubCommands()
    {
      var ctx = new Mod.Context();
      ctx.CurrentItem = _testContent;
      var handler = new Mod.CommandHandler(ctx, new TextOutputFormatter());
      var result = handler.Execute("replace < (ga -a name) B < (echo c) -c");

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(result.Message, Is.EqualTo("cebhionn"));
    }
Ejemplo n.º 11
0
    public void CommandFlagParameter()
    {
      var ctx = new Mod.Context();
      ctx.CurrentItem = _testContent;
      var handler = new Mod.CommandHandler(ctx, new TextOutputFormatter());
      var result = handler.Execute("ls -a -d");

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(result.Message, Is.EqualTo("  phobos\r\n+ Luna\r\n  Deimos\r\n  Adrastea Phobos"));
    }