public void ListAll_None()
    {
      var cmd = new Cmd.SetEnvironmentVariable();
      InitCommand(cmd);

      var result = cmd.Run();

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(result.Message, Contains.Substring("0 variables"));
    }
    public void SetReserved()
    {
      var cmd = new Cmd.SetEnvironmentVariable();
      InitCommand(cmd);

      cmd.Name = "prev";
      cmd.Value = "something";

      var result = cmd.Run();

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Failure));
    }
    public void SetExisting()
    {
      var cmd = new Cmd.SetEnvironmentVariable();
      InitCommand(cmd);

      _context.EnvironmentVariables.Add("lorem", "ipsum");
      cmd.Name = "lorem";
      cmd.Value = "dolor";

      var result = cmd.Run();

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(_context.EnvironmentVariables.Count, Is.EqualTo(1));
      Assert.That(_context.EnvironmentVariables, Contains.Item(new DictionaryEntry("lorem", "dolor")));
    }
    public void ListAll_Some()
    {
      var cmd = new Cmd.SetEnvironmentVariable();
      InitCommand(cmd);

      _context.EnvironmentVariables.Add("lorem", "ipsum");
      _context.EnvironmentVariables.Add("dolor", "sit");

      var result = cmd.Run();

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(result.Message, Contains.Substring("2 variables"));
      Assert.That(result.Message, Is.StringMatching("lorem\\s+ipsum"));
      Assert.That(result.Message, Is.StringMatching("dolor\\s+sit"));
    }
    public void ClearNotExisting()
    {
      var cmd = new Cmd.SetEnvironmentVariable();
      InitCommand(cmd);

      _context.EnvironmentVariables.Add("lorem", "ipsum");
      _context.EnvironmentVariables.Add("dolor", "sit");
      cmd.Name = "amed";

      var result = cmd.Run();

      Assert.That(result.Status, Is.EqualTo(CommandStatus.Success));
      Assert.That(result.Message, Contains.Substring("wasn't set"));
      Assert.That(_context.EnvironmentVariables.Count, Is.EqualTo(2));
      Assert.That(_context.EnvironmentVariables, Contains.Item(new DictionaryEntry("lorem", "ipsum")));
      Assert.That(_context.EnvironmentVariables, Contains.Item(new DictionaryEntry("dolor", "sit")));
    }