Hello,
Unsure how this task is to be carried out as you mentioned string list but are working with if (e.Text.Equals(Employee))
were Employee does not appear to be a string, seems more like an instance of a class???
Now for comparing strings in a list you can consider using SequenceEqual.
Be cognitive that if using SequenceEqual
- Order matters
- Casing matters
Example test
[TestMethod]
[TestTraits(Trait.GeneralComparing)]
public void Compare_string_ArraySequenceEqual_LoweredCase()
{
/*
* Equal as param 2
*/
Assert.IsTrue(MonthNamesArray().SequenceEqual(
MonthNamesLowerCasedArray(),
StringComparer.CurrentCultureIgnoreCase));
/*
* Unequal as case matters
*/
Assert.IsFalse(MonthNamesArray().SequenceEqual(MonthNamesLowerCasedArray()));
}
In a test base class
public static string[] MonthNamesLowerCasedArray() => MonthNamesList().Select(month => month.ToLower()).ToArray();
public static string[] MonthNamesArray() => MonthNamesList().ToArray();
If I'm off base my apologies.