public static CsvDataSheet Download(AbsoluteUri location) { if (null == location) { throw new ArgumentNullException("location"); } CsvDataSheet csv = null; var request = WebRequest.Create((Uri)location); using (var response = request.GetResponse()) { using (var stream = response.GetResponseStream()) { if (null != stream) { using (var reader = new StreamReader(stream)) { #if NET20 var file = new FileInfo(StringExtensionMethods.FormatWith("{0}.csv", AlphaDecimal.Random())); FileInfoExtensionMethods.Create(file, reader.ReadToEnd()); #else var file = new FileInfo("{0}.csv".FormatWith(AlphaDecimal.Random())); file.Create(reader.ReadToEnd()); #endif csv = new CsvDataSheet(file); } } } } return(csv); }
public void op_IEnumerable_GetEnumerator() { using (var file = new TempFile()) { file.Info.AppendLine("name"); file.Info.AppendLine("Example"); IEnumerable enumerable = new CsvDataSheet(file.Info); foreach (var entry in enumerable.Cast <KeyStringDictionary>()) { Assert.Equal("Example", entry["name"]); } } }
public void usage_whenMultipleParameters(CsvDataSheet one, CsvDataSheet two) { Assert.Equal("one", one.First()["COLUMN"]); Assert.Equal("two", two.First()["COLUMN"]); }
public void usage(CsvDataSheet sheet) { Assert.Equal("A1", sheet.First()["A"]); Assert.Equal("B2", sheet.Last()["B"]); }
public void usage(CsvDataSheet csv) { Assert.Equal("A1", csv.First()["A"]); Assert.Equal("B2", csv.Last()["B"]); }