public void ConvertSingleColumn() { DateTime d = new DateTime(1990, 1, 2); Row r = new MockRow(new Dictionary <string, string> { { "value", "32" } }); int result = r.As <int>(); Assert.Equal(32, result); }
public void ConvertCornerCases() { Row r = new MockRow(new Dictionary<string,string> { {"Field", "abc"}, {"Private", "abc"}, {"Readonly", "abc"} // can't be set. }); RowType result = r.As<RowType>(); Assert.Equal(0, result.Age); // missing Assert.Equal(string.Empty, result.Missing); Assert.Null(result.GetPrivate()); Assert.Null(result.Field); }
public void ConvertCornerCases() { Row r = new MockRow(new Dictionary <string, string> { { "Field", "abc" }, { "Private", "abc" }, { "Readonly", "abc" } // can't be set. }); RowType result = r.As <RowType>(); Assert.Equal(0, result.Age); // missing Assert.Equal(string.Empty, result.Missing); Assert.Null(result.GetPrivate()); Assert.Null(result.Field); }
public void ConvertNormal() { DateTime d = new DateTime(1990, 1, 2); string g = "E0B9A23E-29C4-42B5-A6EB-1BEB6EE42BEC"; Row r = new MockRow(new Dictionary<string,string> { {"name", "bob"}, {"age", "15" }, {"date", d.ToShortDateString() }, {"guid", g }, {"fruit", Fruit.Banana.ToString() } }); RowType result = r.As<RowType>(); Assert.Equal("bob", result.Name); Assert.Equal(15, result.Age); Assert.Equal(d, result.Date); Assert.Equal(g, result.Guid.ToString().ToUpper()); Assert.Equal(Fruit.Banana, result.Fruit); }
public void ConvertNormal() { DateTime d = new DateTime(1990, 1, 2); string g = "E0B9A23E-29C4-42B5-A6EB-1BEB6EE42BEC"; Row r = new MockRow(new Dictionary <string, string> { { "name", "bob" }, { "age", "15" }, { "date", d.ToShortDateString() }, { "guid", g }, { "fruit", Fruit.Banana.ToString() } }); RowType result = r.As <RowType>(); Assert.Equal("bob", result.Name); Assert.Equal(15, result.Age); Assert.Equal(d, result.Date); Assert.Equal(g, result.Guid.ToString().ToUpper()); Assert.Equal(Fruit.Banana, result.Fruit); }
public void ConvertSingleColumn() { DateTime d = new DateTime(1990, 1, 2); Row r = new MockRow(new Dictionary<string, string> { {"value", "32"} }); int result = r.As<int>(); Assert.Equal(32, result); }