public void TestParseValues_WrongNumber_Throws() { FixedLengthSchema schema = new FixedLengthSchema(); schema.AddColumn(new StringColumn("name"), 10); schema.ParseValues(new string[] { "bob", "smith" }); }
public void TestParseValues_ParsesValues() { FixedLengthSchema schema = new FixedLengthSchema(); schema.AddColumn(new StringColumn("first_name"), new Window(10)) .AddColumn(new StringColumn("last_name"), new Window(10)) .AddColumn(new DateTimeColumn("birth_date") { InputFormat = "yyyyMMdd" }, new Window(8)) .AddColumn(new Int32Column("weight"), new Window(5)); string[] values = new string[] { "bob", "smith", "20120123", "185" }; var recordContext = new RecordContext() { ExecutionContext = new FixedLengthExecutionContext() { Schema = schema, Options = new FixedLengthOptions() } }; 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() { FixedLengthSchema schema = new FixedLengthSchema(); schema.AddColumn(new StringColumn("first_name"), new Window(10)) .AddColumn(new StringColumn("last_name"), new Window(10)) .AddColumn(new DateTimeColumn("birth_date") { InputFormat = "yyyyMMdd" }, new Window(8)) .AddColumn(new Int32Column("weight"), new Window(5)); 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_NullValues_Throws() { FixedLengthSchema schema = new FixedLengthSchema(); schema.ParseValues(null); }