public void Get_WhenGivenLocationStringMatchingAltName_Returns_LocationId( string altPlaceName, int expectedPlaceId) { // arrange var placesRepository = PlacesRepository(); var placesController = new PlacesController( placesRepository); // act List<Place> places = placesController.GetByLocation(altPlaceName).ToList(); // assert Assert.That(places.First().PlacesID == expectedPlaceId); }
public void Get_WhenTwoMatchingPlaces_Returns_Both() { var placesRepository = MockRepository.GenerateMock<IPlacesRepository>(); placesRepository.Stub(x => x.GetAll()).Return( new List<Place> { new Place { PlacesID = 1, Name = "Walker", County = "North Tyneside", Postcode = "LE14 3" }, new Place { PlacesID = 2, Name = "Middleton", County = "Northamptonshire", Postcode = "LE16 8" }, }); var placesController = new PlacesController( placesRepository); // act var places = placesController.GetByLocation("LE1").ToList(); // assert Assert.That(places.Count == 2); }
public void Get_WhenMatchingCounty_Returns_AllTownsWithinCounty() { const string County = "Northamptonshire"; var placesRepository = MockRepository.GenerateMock<IPlacesRepository>(); placesRepository.Stub(x => x.GetAll()).Return( new List<Place> { new Place { PlacesID = 1, Name = "Achurch", County = County, Postcode = "PE8 5" }, new Place { PlacesID = 2, Name = "Abthorpe", County = County, Postcode = "NN12 8" }, }); var placesController = new PlacesController( placesRepository); // act var places = placesController.GetByLocation(County).ToList(); // assert Assert.That(places.Count == 2); }