title: How to unit test MvvmCross with IMvxMessenger
body: <p>I'm using Xamarin Studio to embark upon TDD using MvvmCross.  I'm trying to first start by testing the effect of messages being published to the view model so that logic is performed only when the appropriate message is recieved.</p>
  
  <p>I've hacked together some of Stuart's excellent tutorials resulting in successful propogation of location data to view models which then update some text controls, map markers, etc on the IOS views. </p>
  
  <p>But before I dive in further I want to code using TDD.  How do I artificially setup the viewmodel and artificially publish the messages to it in my test harness? :</p>
  
  <pre><code>public class MyViewModel : MvxViewModel
  {
      private readonly MvxSubscriptionToken _token;
  
      public MyViewModel(ILocationService service, IMvxMessenger messenger)
      {
          //weak reference
          _token = messenger.Subscribe&lt;LocationMessage&gt;(OnLocationMessage);
      }
  
      private void OnLocationMessage(LocationMessage locationMessage)
      {
          Lat = locationMessage.Lat;
          Lng = locationMessage.Lng;
          // Console.WriteLine("on loc msg {0:0.0000}, {1:0.0000}", Lat, Lng);
      }
  
      private double _lng;
      public double Lng
      {
          get { return _lng; }
          set
          {
              _lng = value;
              RaisePropertyChanged(() =&gt; Lng);
          }
      }
  
      private double _lat;
      public double Lat
      {
          get { return _lat; }
          set
          {
              _lat = value;
              RaisePropertyChanged(() =&gt; Lat);
          }
      }
  }
  
  
  [TestFixture()]
  public class LocTest
  {
      [Test()]
      public void LocationMessageIsRecieved()
      {
          // im using nsubstitute to mock with
          var locService = Substitute.For&lt;ILocationService&gt;();  
          var msgr = Substitute.For&lt;IMvxMessenger&gt;();
          var vm = new Map2ViewModel(locService, msgr);
  
          var locMsg = new LocationMessage(this, 1F, 2F);
          msgr.Publish(locMsg);
  
          var lat = vm.Lat;
          Assert.AreEqual(2F, lat);  // says lat is 0.0  and nunit doesnt let me debug the tests :(
      }
  }
  </code></pre>
  
  <p>Any great tutorials on TDD with MvvmCross would be fantastic </p>