public void TestSetup()
    {
      dte_ = TestUtilities.StartVisualStudioInstance();
      try
      {
        TestUtilities.AssertAddinLoaded(dte_, NativeClientVSAddIn.Strings.AddInName);
      }
      catch
      {
        TestUtilities.CleanUpVisualStudioInstance(dte_);
        throw;
      }

      // Set up mock property manager to return the desired property values.
      properties_ = new MockPropertyManager(
        PropertyManager.ProjectPlatformType.Pepper,
        delegate(string page, string name)
        {
          switch (page)
          {
            case "ConfigurationGeneral":
              switch (name)
              {
                case "VSNaClSDKRoot": return System.Environment.GetEnvironmentVariable(
                    NativeClientVSAddIn.Strings.SDKPathEnvironmentVariable);
              }

              break;
            case "Property":
              switch (name)
              {
                case "ProjectDirectory": return TestContext.DeploymentDirectory;
                case "PluginAssembly": return @"fake\Assembly\String";
              }

              break;
          }

          return null;
        },
        null);
    }
    public void TestSetup()
    {
      dte_ = TestUtilities.StartVisualStudioInstance();
      try
      {
        TestUtilities.AssertAddinLoaded(dte_, NativeClientVSAddIn.Strings.AddInName);
      }
      catch
      {
        TestUtilities.CleanUpVisualStudioInstance(dte_);
        throw;
      }

      // Set up mock property manager to return the desired property values.
      properties_ = new MockPropertyManager(
        PropertyManager.ProjectPlatformType.NaCl,
        delegate(string page, string name)
        {
          switch (page)
          {
            case "ConfigurationGeneral":
              switch (name)
              {
                case "VSNaClSDKRoot": return System.Environment.GetEnvironmentVariable(
                    NativeClientVSAddIn.Strings.SDKPathEnvironmentVariable);
                case "NaClManifestPath": return string.Empty;
                case "ToolchainName": return "newlib";
                case "TargetArchitecture": return "x86_64";
              }

              break;
            case "WindowsLocalDebugger":
              switch (name)
              {
                case "LocalDebuggerCommand":
                  return Environment.GetEnvironmentVariable("CHROME_PATH");
              }
              break;
            case "Property":
              switch (name)
              {
                case "ProjectDirectory": return TestContext.DeploymentDirectory;
                case "PluginAssembly": return @"fake\Assembly\String";
              }

              break;
          }

          return null;
        },
        null);
    }
    public void WebServerConstructorTest()
    {
      OutputWindowPane outputWindowPane = dte_.ToolWindows.OutputWindow.OutputWindowPanes.Add(
          Strings.WebServerOutputWindowTitle);

      // Set up mock property manager to return the desired property values.
      MockPropertyManager properties = new MockPropertyManager(
        PropertyManager.ProjectPlatformType.Pepper,
        delegate(string page, string name)
        {
          switch (page)
          {
            case "ConfigurationGeneral":
              switch (name)
              {
                case "VSNaClSDKRoot": return System.Environment.GetEnvironmentVariable(
                    NativeClientVSAddIn.Strings.SDKPathEnvironmentVariable);
                case "NaClWebServerPort": return "5105";
              }

              break;
            case "Property":
              switch (name)
              {
                case "ProjectDirectory": return TestContext.DeploymentDirectory;
              }

              break;
          }

          return null;
        },
        null);

      WebServer target = null;
      try
      {
        target = new WebServer(outputWindowPane, properties);

        TestUtilities.AssertTrueWithTimeout(
          () => !string.IsNullOrEmpty(TestUtilities.GetPaneText(outputWindowPane)),
          TimeSpan.FromMilliseconds(500),
          20,
          "Pane text never appeared");

        TestUtilities.AssertTrueWithTimeout(
            () => TestUtilities.DoesProcessExist("python.exe", "5105", "httpd.py"),
            TimeSpan.FromMilliseconds(500),
            20,
            "Web server failed to start.");

        target.Dispose();

        TestUtilities.AssertTrueWithTimeout(
            () => !TestUtilities.DoesProcessExist("python.exe", "5105", "httpd.py"),
            TimeSpan.FromMilliseconds(500),
            20,
            "Web server failed to shut down.");
      }
      finally
      {
        if (target != null)
        {
          target.Dispose();
        }
      }
    }