public void PluginDebuggerVSConstructorTest()
    {
      // Check that a null dte fails.
      try
      {
        PluginDebuggerBase nullDte = new PluginDebuggerVS(null, properties_);
        Assert.Fail("Using null DTE instance did not throw exception");
      }
      catch (ArgumentNullException)
      {
        // This is expected for a correct implementation.
      }
      catch
      {
        Assert.Fail("Using null DTE instance threw something other than ArgumentNullException");
      }

      // Check that a null PropertyManager fails.
      try
      {
        PluginDebuggerBase nullDte = new PluginDebuggerVS(dte_, null);
        Assert.Fail("Using null property manager did not throw exception");
      }
      catch (ArgumentNullException)
      {
        // This is expected for a correct implementation.
      }
      catch
      {
        Assert.Fail("Using null property manager threw something other than ArgumentNullException");
      }
    }
    public void FindAndAttachToPepperPluginTest()
    {
      MockProcessSearcher processResults = new MockProcessSearcher();

      using (PluginDebuggerVS target = new PluginDebuggerVS(dte_, properties_))
      {
        PluginDebuggerBase_Accessor targetBase = new PluginDebuggerBase_Accessor(
            new PrivateObject(target, new PrivateType(typeof(PluginDebuggerBase))));
        targetBase.debuggedChromeMainProcess_ = System.Diagnostics.Process.GetCurrentProcess();
        uint currentProcId = (uint)targetBase.debuggedChromeMainProcess_.Id;

        string pluginLoadFlag = string.Format(
            Strings.PepperProcessPluginFlagFormat, properties_.PluginAssembly);
        string pepperCommandLine = string.Concat(
            pluginLoadFlag, " ", Strings.ChromeRendererFlag);

        // Fake the list of processes on the system.
        processResults.ProcessList.Add(
            new ProcessInfo(
                currentProcId,
                currentProcId,
                string.Empty,
                Strings.NaClDebugFlag,
                Strings.ChromeProcessName));
        processResults.ProcessList.Add(
            new ProcessInfo(1, currentProcId, string.Empty, string.Empty, "MyParentProcess"));
        processResults.ProcessList.Add(
            new ProcessInfo(10, 1, string.Empty, pepperCommandLine, Strings.ChromeProcessName));

        // This is missing some relevant command line args, and should not be attached to.
        processResults.ProcessList.Add(
            new ProcessInfo(12, 1, string.Empty, pluginLoadFlag, Strings.ChromeProcessName));

        // This doesn't have this process as its parent, and should not be attached to.
        processResults.ProcessList.Add(
            new ProcessInfo(14, 14, string.Empty, pepperCommandLine, Strings.ChromeProcessName));

        // Set the private value to the mock object (can't use accessor since no valid cast).
        FieldInfo processSearcherField = typeof(PluginDebuggerBase).GetField(
            "processSearcher_",
            BindingFlags.NonPublic | BindingFlags.Instance);
        processSearcherField.SetValue(targetBase.Target, processResults);

        // Test that the correct processes are attached to.
        bool goodPepper = false;
        var handler = new EventHandler<NativeClientVSAddIn.PluginDebuggerBase.PluginFoundEventArgs>(
          delegate(object unused, NativeClientVSAddIn.PluginDebuggerBase.PluginFoundEventArgs args)
          {
            switch (args.ProcessID)
            {
              case 10:
                if (goodPepper)
                {
                  Assert.Fail("Should not attach twice to same pepper process");
                }

                goodPepper = true;
                break;
              case 12:
                Assert.Fail("Should not attach to pepper process with bad args");
                break;
              case 14:
                Assert.Fail("Should not attach to pepper process that is not "
                          + "descendant of Visual Studio");
                break;
              default:
                Assert.Fail("Should not attach to non-pepper/non-nacl process");
                break;
            }
          });

        target.PluginFoundEvent += handler;
        target.FindAndAttachToPlugin(null, null);
        target.PluginFoundEvent -= handler;

        Assert.IsTrue(goodPepper, "Failed to attach to pepper process");
      }
    }