Created
October 9, 2012 18:34
-
-
Save JefClaes/3860582 to your computer and use it in GitHub Desktop.
Command an query handlers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod()] | |
public void Foo_should_start_mspaint() | |
{ | |
var cmdHandler = new Mock<ICommandHandler>(); | |
var qryHandler = new Mock<IQueryHandler>(); | |
var controller = new Controller(cmdHandler.Object, qryHandler.Object); | |
controller.Foo("mspaint.exe"); | |
cmdHandler.Verify(h => h.Execute(It.Is<StartProcessCommand>(c => c.Filename == "mspaint.exe"))); | |
} | |
[TestMethod()] | |
public void Foo_should_return_the_number_of_processes() | |
{ | |
var cmdHandler = new Mock<ICommandHandler>(); | |
var qryHandler = new Mock<IQueryHandler>(); | |
qryHandler | |
.Setup(h => h.Execute<int>(It.IsAny<ProcessCountQuery>())) | |
.Returns(4); | |
var controller = new Controller(cmdHandler.Object, qryHandler.Object); | |
Assert.AreEqual(4, controller.Foo("test.exe")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment