Created
April 10, 2020 22:47
-
-
Save ankitvijay/d4a5cc1172489c0c581f08bc32e66e28 to your computer and use it in GitHub Desktop.
xUnitMemberDataExample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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