Skip to content

Instantly share code, notes, and snippets.

@ankitvijay
Created April 10, 2020 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ankitvijay/d4a5cc1172489c0c581f08bc32e66e28 to your computer and use it in GitHub Desktop.
Save ankitvijay/d4a5cc1172489c0c581f08bc32e66e28 to your computer and use it in GitHub Desktop.
xUnitMemberDataExample
public class AnimalRepository
{
private readonly List<string> _animals = new List<string>()
{
"TIGER",
"LION",
"DOG",
"CAT",
"COW",
"PIG"
};
public string Find(SearchCriteria searchCriteria)
{
if (searchCriteria == null)
{
throw new ArgumentNullException(nameof(searchCriteria));
}
return _animals.FirstOrDefault(e => e.Contains(searchCriteria.SearchTerm,
searchCriteria.IgnoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal));
}
}
public class SearchCriteria
{
public SearchCriteria(string searchTerm, bool ignoreCase = false)
{
SearchTerm = searchTerm ?? throw new ArgumentNullException(nameof(searchTerm));
IgnoreCase = ignoreCase;
}
public string SearchTerm { get; }
public bool IgnoreCase { get; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment