public void IsMatchTests(string name, double quantity, string units, string searchTerm, bool expected) { // Arrange var term = IngredientSearchTerm.Parse(searchTerm); // Act var actual = term.IsMatch(name, quantity, units); // Assert Assert.Equal(expected, actual); }
public static bool IsMatch <T>(this IEnumerable <T> ingredients, string query) where T : IIngredient { if (ingredients == null) { return(false); } var searchTerm = IngredientSearchTerm.Parse(query); if (searchTerm == null) { // TODO: Perhaps this should raise an exception return(false); } return(ingredients.Any(x => searchTerm.IsMatch(x))); }