IProxy implementation to allow CSV as the input to Duck.Implement
$ dotnet add package Shadow.Quack.CsvThis package allows the easy population of values directly from a CSV string into a dynamically implemented immutable IEnumerable<T> where T is a dynamically implemented immutable interface with the help of the base Shadow Quack package.
This means that there is almost no effort in importing from a CSV file or string to an IEnumerable<T> with no need for concrete implementations or additional code.
public interface ITestCsv
{
string AccountRef { get; }
string CompanyName { get; }
IEnumerable<string> ProductTypes { get; }
int MinUnits { get; }
int MaxUnits { get; }
DateTime StartDate { get; }
object LocalTaxRate { get; }
int FixedCommission { get; }
decimal Discount { get; }
bool Boolean { get; }
}
This works on the assumption that the first row in the CSV file containing headings that match the interface properties
CsvProxy csvContent =
@"AccountRef,CompanyName,MinUnits,MaxUnits,Boolean,ProductTypes,StartDate,LocalTaxRate,Discount,FixedCommission
XVVT-1987UT565,Narcolepsy Pumpkin,0,60,TRUE,""Data,Telephone"",17/12/2000,,3.9%,120
xxxx-1987UT565,Narcolepsy Pumpkin,0,60,TRUE,""Data,Telephone"",17/12/2001,,3.9%,120";
var result = Duck.Implement<IEnumerable<ITestCsv>>(csvContent);
Useful for mock data required for unit tests, and importing tabular data from CSV files.