public void TwoRows()
		{
			var data = new ArrayList();

			data.Add(new object[] {26, "hammett", "r pereira leite 44"});
			data.Add(new object[] {27, "his girl", "barao bananal 100"});

			var reader = new MockDataReader(data, new[] {"age", "name", "address"}, typeof (int), typeof (String),
			                                typeof (String));

			var binder = new DataBinder();

			var contacts =
				(Contact[])
				binder.BindObject(typeof (Contact[]), "cont", new DataReaderTreeBuilder().BuildSourceNode(reader, "cont"));

			Assert.IsNotNull(contacts);
			Assert.AreEqual(2, contacts.Length);

			Assert.AreEqual(26, contacts[0].Age);
			Assert.AreEqual("hammett", contacts[0].Name);
			Assert.AreEqual("r pereira leite 44", contacts[0].Address);

			Assert.AreEqual(27, contacts[1].Age);
			Assert.AreEqual("his girl", contacts[1].Name);
			Assert.AreEqual("barao bananal 100", contacts[1].Address);
		}
        public void UsingTranslator()
        {
            var data = new ArrayList();

            data.Add(new object[] { 26, "hammett", "r pereira leite 44" });
            data.Add(new object[] { 27, "his girl", "barao bananal 100" });

            var reader = new MockDataReader(data, new[] { "idade", "nome", "endereco" }, typeof(int), typeof(String),
                                            typeof(String));

            var binder = new DataBinder();

            binder.Translator = new EnglishToPortugueseTranslator();

            var contacts =
                (Contact[])
                binder.BindObject(typeof(Contact[]), "cont", new DataReaderTreeBuilder().BuildSourceNode(reader, "cont"));

            Assert.IsNotNull(contacts);
            Assert.AreEqual(2, contacts.Length);

            Assert.AreEqual(26, contacts[0].Age);
            Assert.AreEqual("hammett", contacts[0].Name);
            Assert.AreEqual("r pereira leite 44", contacts[0].Address);

            Assert.AreEqual(27, contacts[1].Age);
            Assert.AreEqual("his girl", contacts[1].Name);
            Assert.AreEqual("barao bananal 100", contacts[1].Address);
        }
		public void EmptyReader()
		{
			ArrayList data = new ArrayList();

			MockDataReader reader = new MockDataReader(data, new string[] { "name", "address"});
			
			DataBinder binder = new DataBinder();

			Contact[] contacts = (Contact[]) binder.BindObject(typeof(Contact[]), "cont", new DataReaderTreeBuilder().BuildSourceNode(reader, "cont"));

			Assert.IsNotNull(contacts);
			Assert.AreEqual(0, contacts.Length);
		}
        public void EmptyReader()
        {
            var data = new ArrayList();

            var reader = new MockDataReader(data, new[] { "name", "address" });

            var binder = new DataBinder();

            var contacts =
                (Contact[])
                binder.BindObject(typeof(Contact[]), "cont", new DataReaderTreeBuilder().BuildSourceNode(reader, "cont"));

            Assert.IsNotNull(contacts);
            Assert.AreEqual(0, contacts.Length);
        }
		public void SingleRow()
		{
			ArrayList data = new ArrayList();

			data.Add( new object[] { "hammett", "r pereira leite 44" } );

			MockDataReader reader = new MockDataReader(data, new string[] { "name", "address"}, typeof(String), typeof(String));
			
			DataBinder binder = new DataBinder();

			Contact[] contacts = (Contact[]) binder.BindObject(typeof(Contact[]), "cont", new DataReaderTreeBuilder().BuildSourceNode(reader, "cont"));

			Assert.IsNotNull(contacts);
			Assert.AreEqual(1, contacts.Length);
			Assert.AreEqual("hammett", contacts[0].Name);
			Assert.AreEqual("r pereira leite 44", contacts[0].Address);
		}
		public void UsingTypeConverter()
		{
			ArrayList data = new ArrayList();

			data.Add( new object[] { "hammett", "r pereira leite 44", new DateTime(2006,7,16) } );

			MockDataReader reader = new MockDataReader(data, new string[] { "name", "address", "dob" }, typeof(String), typeof(String), typeof(DateTime));
			
			DataBinder binder = new DataBinder();

			Contact[] contacts = (Contact[]) binder.BindObject(typeof(Contact[]), "cont", new DataReaderTreeBuilder().BuildSourceNode(reader, "cont"));

			Assert.IsNotNull(contacts);
			Assert.AreEqual(1, contacts.Length);
			Assert.AreEqual("hammett", contacts[0].Name);
			Assert.AreEqual("r pereira leite 44", contacts[0].Address);
			Assert.IsTrue(contacts[0].DOB.HasValue);
		}
        public void SingleRow()
        {
            var data = new ArrayList();

            data.Add(new object[] { "hammett", "r pereira leite 44" });

            var reader = new MockDataReader(data, new[] { "name", "address" }, typeof(String), typeof(String));

            var binder = new DataBinder();

            var contacts =
                (Contact[])
                binder.BindObject(typeof(Contact[]), "cont", new DataReaderTreeBuilder().BuildSourceNode(reader, "cont"));

            Assert.IsNotNull(contacts);
            Assert.AreEqual(1, contacts.Length);
            Assert.AreEqual("hammett", contacts[0].Name);
            Assert.AreEqual("r pereira leite 44", contacts[0].Address);
        }
        public void UsingTypeConverter()
        {
            var data = new ArrayList();

            data.Add(new object[] { "hammett", "r pereira leite 44", new DateTime(2006, 7, 16) });

            var reader = new MockDataReader(data, new[] { "name", "address", "dob" }, typeof(String), typeof(String),
                                            typeof(DateTime));

            var binder = new DataBinder();

            var contacts =
                (Contact[])
                binder.BindObject(typeof(Contact[]), "cont", new DataReaderTreeBuilder().BuildSourceNode(reader, "cont"));

            Assert.IsNotNull(contacts);
            Assert.AreEqual(1, contacts.Length);
            Assert.AreEqual("hammett", contacts[0].Name);
            Assert.AreEqual("r pereira leite 44", contacts[0].Address);
            Assert.IsTrue(contacts[0].DOB.HasValue);
        }
		public void UsingTranslator()
		{
			ArrayList data = new ArrayList();

			data.Add( new object[] { 26, "hammett", "r pereira leite 44" } );
			data.Add( new object[] { 27, "his girl", "barao bananal 100" } );

			MockDataReader reader = new MockDataReader(data, new string[] { "idade", "nome", "endereco"}, typeof(int), typeof(String), typeof(String));
			
			DataBinder binder = new DataBinder();
			binder.Translator = new EnglishToPortugueseTranslator();

			Contact[] contacts = (Contact[]) binder.BindObject(typeof(Contact[]), "cont", new DataReaderTreeBuilder().BuildSourceNode(reader, "cont"));

			Assert.IsNotNull(contacts);
			Assert.AreEqual(2, contacts.Length);
			
			Assert.AreEqual(26, contacts[0].Age);
			Assert.AreEqual("hammett", contacts[0].Name);
			Assert.AreEqual("r pereira leite 44", contacts[0].Address);

			Assert.AreEqual(27, contacts[1].Age);
			Assert.AreEqual("his girl", contacts[1].Name);
			Assert.AreEqual("barao bananal 100", contacts[1].Address);
		}