Example #1
0
    public void BindCustomCommand_MissingCommand()
    {
      var formatter = new TextOutputFormatter();

      var ctx = new Core.Context();
      ctx.CommandHandler = new Core.CommandHandler(ctx, formatter);

      var cmd = new Mod.BindCommand();
      cmd.Initialise(ctx, formatter);

      cmd.CommandName = "c";

      var result = cmd.Run();

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Failure));
    }
Example #2
0
    public void BindCustomCommand()
    {
      var formatter = new TextOutputFormatter();

      var ctx = new Core.Context();
      ctx.CommandHandler = new Core.CommandHandler(ctx, formatter);

      var cmd = new Mod.BindCommand();
      cmd.Initialise(ctx, formatter);

      cmd.Command = "Revolver.Test.BindCommand+CustomCommand, Revolver.Test";
      cmd.CommandName = "c";

      var result = cmd.Run();

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(ctx.CommandHandler.CustomCommands, Contains.Item(new KeyValuePair<string, Type>("c", typeof(CustomCommand))));
    }
Example #3
0
    public void ListBindings()
    {
      var formatter = new TextOutputFormatter();

      var ctx = new Core.Context();
      ctx.CommandHandler = new Core.CommandHandler(ctx, formatter);

      var cmd = new Mod.BindCommand();
      cmd.Initialise(ctx, formatter);

      var result = cmd.Run();

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success), result.Message);
      Assert.That(result.Message, Contains.Substring("cd"));
      Assert.That(result.Message, Contains.Substring("ls"));
    }
Example #4
0
    public void RemoveAlias()
    {
      var formatter = new TextOutputFormatter();

      var ctx = new Core.Context();
      ctx.CommandHandler = new Core.CommandHandler(ctx, formatter);
      ctx.CommandHandler.AddCustomCommand("c", typeof(CustomCommand));
      ctx.CommandHandler.AddCommandAlias("cc", "c");

      var cmd = new Mod.BindCommand();
      cmd.Initialise(ctx, formatter);

      cmd.Remove = true;
      cmd.CommandName = "cc";
      cmd.ProcessAsAlias = true;

      var result = cmd.Run();

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success), result.Message);
      Assert.That(ctx.CommandHandler.CustomCommands, Contains.Item(new KeyValuePair<string, Type>("c", typeof(CustomCommand))));

      var cmdArgs = ctx.CommandHandler.FindCommandAlias("cc");

      Assert.That(cmdArgs, Is.Null);
    }
Example #5
0
    public void RemoveCustomCommand()
    {
      var formatter = new TextOutputFormatter();

      var ctx = new Core.Context();
      ctx.CommandHandler = new Core.CommandHandler(ctx, formatter);
      ctx.CommandHandler.AddCustomCommand("c", typeof (CustomCommand));

      var cmd = new Mod.BindCommand();
      cmd.Initialise(ctx, formatter);

      cmd.CommandName = "c";
      cmd.Remove = true;

      var result = cmd.Run();

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(ctx.CommandHandler.CustomCommands, Is.Not.Contains(new KeyValuePair<string, Type>("c", typeof(CustomCommand))));
    }