title: Rewriting OS-query method to become testable
body: <p>I'm going through our application's unit tests and improving/adding more of them. I'm quite (<em>no, very</em>) novice in unit testing/test-driven development and I found the following method that I wanted to test. I'm stuck, and my question is if there's a way to rewrite this so that it is testable?</p>
  
  <pre><code>public static bool Is32BitOS()
  {
          string os = (from x in new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem").Get().OfType&lt;ManagementObject&gt;()
                       select x.GetPropertyValue("Caption")).First().ToString().Trim();
  
          if (os.Equals("Microsoft Windows XP Professional"))
          {
              return true;
          }
  
          if (os.StartsWith("Microsoft Windows 7"))
          {
              string architecture = (from x in new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem").Get().OfType&lt;ManagementObject&gt;()
                                     select x.GetPropertyValue("OSArchitecture")).First().ToString();
              if (architecture == "64-bit")
              {
                  return false;
              }
          }
  
          return true;
  }
  </code></pre>