title: Unit testing with Mock when viewmodel contains an ICommand
body: <p>I have a class (for simplicity I'll call it MyCustomCommand) which basically accepts two Delegates for Execute and CanExecute.  This class implements ICommand.  This then allows me to declare a property in my view model which I bind to from XAML.</p>
  
  <p>The problem is I've run into a scenario where I need to Mock the view model due to a dependency in one of my commands called ApplyChangesCommand.  I'm not convinced the dependency is a bad thing yet.  It's relatively necessary at this point.</p>
  
  <p>Because of this dependency, I'm using Mock Setups to create a Callback which basically "does nothing" to circumvent the dependency.</p>
  
  <p>Now that I've Mock'd the view model, any instance properties are of course now null.  This includes my commands.</p>
  
  <p>Simple example would be:</p>
  
  <pre><code>private void _somethingToExecute;
  public ICommand ApplyChangesCommand { get { return MyCustomCommand(_somethingToExecute, e=&gt;true); }
  </code></pre>
  
  <p>Is there any way with Mock that I can actually invoke ApplyChangesCommand's _somethingToExecute?  Callbase doesn't cut it and I can't think of any other way to do it.</p>
  
  <p>One workaround is to make "_somethingToExecute" public and create the ApplyChangesCommand in my test, but I'm not a fan.</p>
  
  <p>Any advice appreciated.</p>
  
  <p>Thanks</p>