title: How do i Unit Test my RelayCommand using Moq?
body: <p>I have a RelayCommand Class which implements the ICommand interface and it takes a new Action as the parameter for its constructor. It is pretty basic</p>
  
  <p>For example here is how i use command when a button is clicked. And this code is in the constructor of my ViewModel.</p>
  
  <p>All this code does is opens a FolderBrowserDialog and lets the user select a folder.</p>
  
  <pre><code>OutputSelect = new RelayCommand(new Action&lt;object&gt;(folderSelect));
  </code></pre>
  
  <p>This is a method in the viewModel class</p>
  
  <pre><code>public void folderSelect(object obj)
          {
              var dlg = new FolderBrowserDialog();
  
  
              Nullable&lt;bool&gt; result = dlg.ShowDialog();
  
              if (result == true)
              {
                  // Open document             
                  string filename = dlg.SelectedPath;
                  _model.OutputFolder = filename;
              }
          }
  </code></pre>
  
  <p>Once the button is clicked the method folderSelect is run.</p>
  
  <p>Now I am wondering how do I unit test this feature of my Application?</p>
  
  <p>Do i make a Mock for a Action and pass that into my viewModel.OutputSelect.Execute()?</p>