public void TestParseValues_ParsesValues() { SeparatedValueSchema schema = new SeparatedValueSchema(); schema.AddColumn(new StringColumn("first_name")) .AddColumn(new StringColumn("last_name")) .AddColumn(new DateTimeColumn("birth_date") { InputFormat = "yyyyMMdd" }) .AddColumn(new Int32Column("weight")); string[] values = new string[] { "bob", "smith", "20120123", "185" }; var recordContext = new RecordContext() { ExecutionContext = new SeparatedValueExecutionContext() { Schema = schema, Options = new SeparatedValueOptions() } }; object[] parsed = schema.ParseValues(recordContext, values); object[] expected = new object[] { "bob", "smith", new DateTime(2012, 1, 23), 185 }; CollectionAssert.AreEqual(expected, parsed); }
public void TestParseValues_ParsesValues() { SeparatedValueSchema schema = new SeparatedValueSchema(); schema.AddColumn(new StringColumn("first_name")) .AddColumn(new StringColumn("last_name")) .AddColumn(new DateTimeColumn("birth_date") { InputFormat = "yyyyMMdd" }) .AddColumn(new Int32Column("weight")); string[] values = new string[] { "bob", "smith", "20120123", "185" }; object[] parsed = schema.ParseValues(values); object[] expected = new object[] { "bob", "smith", new DateTime(2012, 1, 23), 185 }; CollectionAssert.AreEqual(expected, parsed, "The values were not parsed as expected."); }
public void TestParseValues_ParsesValues() { SeparatedValueSchema schema = new SeparatedValueSchema(); schema.AddColumn(new StringColumn("first_name")) .AddColumn(new StringColumn("last_name")) .AddColumn(new DateTimeColumn("birth_date") { InputFormat = "yyyyMMdd" }) .AddColumn(new Int32Column("weight")); string[] values = new string[] { "bob", "smith", "20120123", "185" }; object[] parsed = schema.ParseValues(values); object[] expected = new object[] { "bob", "smith", new DateTime(2012, 1, 23), 185 }; CollectionAssert.AreEqual(expected, parsed, "The values were not parsed as expected."); }