public void FindByShould_CallPlaceServiceMethodFindInAddress_WhenSearchByIsAddress(string category, string searchBy, string pattern) { var placeServiceMock = new Mock <IPlaceService>(); var service = new Services.SearchService(placeServiceMock.Object); service.FindBy(category, searchBy, pattern); placeServiceMock.Verify(s => s.FindInAddress(category, pattern)); }
public void FindByShould_ReturnCorrectResult_WhenSearchByIsDescription(string category, string searchBy, string pattern) { var placeServiceMock = new Mock <IPlaceService>(); var service = new Services.SearchService(placeServiceMock.Object); var place = new Place() { Details = "Pesho's place" }; var list = new List <Place>() { place }; placeServiceMock.Setup(s => s.FindInDescription(category, pattern)).Returns(list.AsQueryable()); var result = service.FindBy(category, searchBy, pattern); Assert.Contains(place, result.ToList()); }
public void FindByShould_ReturnCorrectResult_WhenSearchByIsAddress(string category, string searchBy, string pattern) { var placeServiceMock = new Mock <IPlaceService>(); var service = new Services.SearchService(placeServiceMock.Object); var address = new Address() { Street = "Pesho's street" }; var place = new Place() { Address = address }; var list = new List <Place>() { place }; placeServiceMock.Setup(s => s.FindInAddress(category, pattern)).Returns(list.AsQueryable()); var result = service.FindBy(category, searchBy, pattern); Assert.Contains(place, result.ToList()); }