Created
May 15, 2013 18:20
-
-
Save k0stya/5586104 to your computer and use it in GitHub Desktop.
SpecFlow CreateSimpleSet
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
namespace TechTalk.SpecFlow | |
{ | |
public static class SpecFlowExt | |
{ | |
public static IEnumerable<T> CreateSimpleSet<T>(this Table table, string colName = null) | |
{ | |
if (table.Rows.Count == 0) | |
{ | |
throw new ApplicationException("Input table is empty"); | |
} | |
if (typeof (T).IsEnum) | |
{ | |
return table.Rows.Select(r => (T)Enum.Parse(typeof(T), colName == null ? r[0] : r[colName])).ToList(); | |
} | |
throw new NotImplementedException(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment