Created
July 27, 2011 06:12
-
-
Save timwingfield/1108778 to your computer and use it in GitHub Desktop.
Setting up a Mock with Moq
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
[TestFixture] | |
public class When_saving_a_vehicle_in_the_view_model_with_a_vehicle : Specification | |
{ | |
private VehicleViewModel _viewModel; | |
private Mock<IVehicleRepository> _repository; | |
protected override void before_each() | |
{ | |
_repository = new Mock<IVehicleRepository>(); | |
_viewModel = new VehicleViewModel(_repository.Object); | |
_viewModel.Name = "New Vehicle"; | |
} | |
protected override void because() | |
{ | |
_viewModel.Save(); | |
} | |
[Test] | |
public void then_save_on_the_repository_should_be_called() | |
{ | |
_repository.Verify(x => x.Save(It.IsAny<Vehicle>()), Times.Exactly(1)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment