Skip to content

Instantly share code, notes, and snippets.

@laurentkempe
Created April 5, 2013 13:45
Show Gist options
  • Save laurentkempe/5319365 to your computer and use it in GitHub Desktop.
Save laurentkempe/5319365 to your computer and use it in GitHub Desktop.
Fluent interface to test MVVMLight Messenger
[Test, RequiresSTA]
public void DeleteBrickCommand_BrickSelected_ExpectEnableMainWindowMessageSentWithFalseThenTrue()
{
//Arrange
var productViewModel = makeProductViewModel();
var brick = productViewModel.AddBrick();
var rootGraphSourceViewModel = new RootGraphSourceViewModel();
rootGraphSourceViewModel.Initialize(productViewModel);
rootGraphSourceViewModel.Show();
brick.IsSelected = true;
//Act
//Assert
rootGraphSourceViewModel.Expect()
.SendingMessages<EnableMainWindowMessage, bool>(new [] { false, true })
.When(model => model.DeleteBrickCommand.Execute(null));
}
@laurentkempe
Copy link
Author

Testing that the message EnableMainWindowMessage with the value false is sent then with the value true when the DeleteBrickCommand is executed.

@dennisdoomen
Copy link

Have you considered extending FluentAssertions (http://fluentassertions.codeplex.com/) for that? And something similar was done for MVC in another project (https://fluentassertionsmvc.codeplex.com/).

@laurentkempe
Copy link
Author

@dennisdoomen Thanks! No I haven't at the moment, but this is also why I posted that, to get some idea!
btw the MVC project is not really relevant as I target MVVMLight so WPF, Silverlight and Win8 Metro and Windows Phone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment