Skip to content

Instantly share code, notes, and snippets.

@glennblock
Created October 11, 2010 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glennblock/619758 to your computer and use it in GitHub Desktop.
Save glennblock/619758 to your computer and use it in GitHub Desktop.
using Microsoft.Practices.Composite.Presentation.Events;
using Microsoft.Practices.Composite.Regions;
using Microsoft.Practices.Unity;
namespace SomeNamespace
{
public class SomeViewModel
{
private readonly IUnityContainer _container;
private readonly IEventAggregator _eventAggregator;
private readonly IRegionManager _regionManager;
public ShellViewModel(IUnityContainer container, IEventAggregator eventAggregator, IRegionManager regionManager)
{
_container = container;
_eventAggregator = eventAggregator;
_regionManager = regionManager;
_eventAggregator.Subscribe<SomeEventPayload>(SomeAction, ThreadOption.UIThread, true);
}
}
[TestFixture]
public class ShellViewModelTests {
[Test]
public void when_vm_is_created_then_subscribes_to_SomeEvent() {
var ea = new Mock<IEventAggregator>();
var vm = new ShellViewModel(null, ea, null);
ea.Verify.... //verify that Subscribe was called on EA which Subscribe calls
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment