Skip to content

Instantly share code, notes, and snippets.

@timwingfield
Created July 27, 2011 06:02
Show Gist options
  • Save timwingfield/1108768 to your computer and use it in GitHub Desktop.
Save timwingfield/1108768 to your computer and use it in GitHub Desktop.
Setting up a Stub with Moq
[TestFixture]
public class When_loading_the_vehicle_list_and_there_two_available_vehicles : Specification
{
protected Mock<IVehicleRepository> _vehicleRepository;
protected List<Vehicle> _vehicles;
protected VehicleViewModel _vehicleViewModel;
protected override void before_each()
{
_vehicles = new List<Vehicle>{ new Vehicle(), new Vehicle() };
_vehicleRepository.Setup(x => x.GetAll()).Returns(_vehicles);
_vehicleViewModel = new VehicleViewModel(_vehicleRepository.Object);
}
[Test]
public void then_the_vehicles_list_should_have_two_vehicles()
{
_vehicleViewModel.VehicleList.Count.Should().Equal(2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment