Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void Parser()
        {
            //var parser = StrongTypeBinder.BuildMethod<Customer>();
            //var values = new Dictionary<string, string> { { "Name", "Bob" }, { "Age", "15" } };
            //var c = parser(values);

            Row r = new MockRow(new Dictionary <string, string> {
                { "name", "bob" },
                { "age", "15" }
            });
            var parser = StrongTypeBinder.BuildMethod <Customer>(r.ColumnNames);
            var c      = parser(r);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        public void Parser()
        {
            //var parser = StrongTypeBinder.BuildMethod<Customer>();
            //var values = new Dictionary<string, string> { { "Name", "Bob" }, { "Age", "15" } };
            //var c = parser(values);

            Row r = new MockRow(new Dictionary<string, string> {
                {"name", "bob"},
                {"age", "15" }
            });
            var parser = StrongTypeBinder.BuildMethod<Customer>(r.ColumnNames);
            var c = parser(r);
        }
Ejemplo n.º 8
0
        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);
        }