Exemplo n.º 1
0
        public void TestSimpleUpdate()
        {
            MockSimpleObject obj = new MockSimpleObject();

            string[] key = new string[] { "ID" };
            //obj.DBUpdateKey = key;
            obj.Id         = 99;
            obj.CommonName = "object1";
            obj.CreateDate = DateTime.Today;
            obj.FullName   = "Object One";
            obj.Status     = 1;
            OleDbConnection con = new OleDbConnection(connectString);

            con.Open();
            SimpleDAO.SimpleDAO <MockSimpleObject> dao   = new SimpleDAO.SimpleDAO <MockSimpleObject>();
            Dictionary <string, string>            props = new Dictionary <string, string>();

            props.Add("Id", "ID");
            props.Add("CommonName", "COMMON_NAME");
            props.Add("FullName", "FULL_NAME");
            props.Add("Status", "STATUS");
            dao.SimpleUpdate(con, obj); //, props);
            con.Close();
            Assert.Inconclusive("nothing to assert");
        }
Exemplo n.º 2
0
        public void TestSimpleSelect()
        {
            MockSimpleObject criteria = new MockSimpleObject();

            criteria.Id = 5;
            OleDbConnection con = new OleDbConnection(connectString);

            //OracleConnection con = new OracleConnection(connectString);
            con.Open();
            SimpleDAO.SimpleDAO <MockSimpleObject> dao = new SimpleDAO.SimpleDAO <MockSimpleObject>(':');

            MockSimpleObject newObj = dao.SimpleSelect(con, criteria);

            Assert.AreEqual(newObj.Id, 5);
            newObj = null;

            Dictionary <string, string> props = new Dictionary <string, string>();

            props.Add("Id", null);
            props.Add("CommonName", null);
            props.Add("FullName", "FULL_NAME");
            newObj = dao.SimpleSelect(con, criteria, props);
            con.Close();
            Assert.AreEqual(newObj.Id, 5);
        }
Exemplo n.º 3
0
        public void TestSimpleSelectWithSQL()
        {
            MockSimpleObject criteria = new MockSimpleObject();

            criteria.Id      = 5;
            criteria.DBTable = "SELECT * FROM MOCK_SIMPLE WHERE ID= @Id AND COMMON_NAME=@CommonName AND FULL_NAME =@FullName";
            //obj.DBTable = "SELECT * FROM SOME_TABLE WHERE ID= ? AND COMMON_NAME=? AND FULL_NAME =? AND COL3=?";
            OleDbConnection con = new OleDbConnection(connectString);

            con.Open();
            SimpleDAO.SimpleDAO <MockSimpleObject> dao = new SimpleDAO.SimpleDAO <MockSimpleObject>();
            MockSimpleObject newObj = dao.SimpleSelect(con, criteria);

            Assert.AreEqual(criteria.Id, newObj.Id);
            newObj = null;

            Dictionary <string, string> props = new Dictionary <string, string>();

            props.Add("Id", null);
            props.Add("CommonName", null);
            props.Add("FullName", "full_name");
            newObj = dao.SimpleSelect(con, criteria, props);
            con.Close();
            Assert.AreEqual(newObj.Id, 5);
            con.Close();
        }
Exemplo n.º 4
0
        public void GetDBUpdateKeysTest()
        {
            MockSimpleObject obj = new MockSimpleObject();

            string[] expected = new string[] { "MOCK_SIMPLE_ID" };
            string[] actual   = ReflectionUtils.InferDBUpdateKeys(obj);
            Assert.AreEqual(expected[0], actual[0]);
        }
Exemplo n.º 5
0
 public void TestSimpleDelete()
 {
     MockSimpleObject obj = new MockSimpleObject();
     obj.Id = 99;
     //            SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=JPAS;User ID=jpas_user;Password=jpas2007");
     OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dev\SimpleDAO\SimpleDAOTest\SimpleDAO.mdb");
     con.Open();
     SimpleDAO.SimpleDAO<MockSimpleObject> dao = new SimpleDAO.SimpleDAO<MockSimpleObject>();
     dao.NullStringValue = null;
     dao.NullIntValue = 0;
     dao.SimpleDelete(con, obj);
     con.Close();
 }
Exemplo n.º 6
0
 public void TestSimpleInsert()
 {
     MockSimpleObject obj = new MockSimpleObject();
     obj.CommonName = "testInsert";
     obj.CreateDate = DateTime.Today;
     obj.FullName = "Test Insert";
     obj.Id = 99;
     obj.Status = 4;
     //SqlConnection con = new SqlConnection(@"Data Source=(local);Initial Catalog=JPAS;User ID=jpas_user;Password=jpas2007");
     OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dev\SimpleDAO\SimpleDAOTest\SimpleDAO.mdb");
     con.Open();
     SimpleDAO.SimpleDAO<MockSimpleObject> dao = new SimpleDAO.SimpleDAO<MockSimpleObject>();
     dao.SimpleInsert(con, obj);
     con.Close();
 }
Exemplo n.º 7
0
        public void TestSimpleDelete()
        {
            MockSimpleObject obj = new MockSimpleObject();

            obj.Id = 99;
//            SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=JPAS;User ID=jpas_user;Password=jpas2007");
            OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dev\SimpleDAO\SimpleDAOTest\SimpleDAO.mdb");

            con.Open();
            SimpleDAO.SimpleDAO <MockSimpleObject> dao = new SimpleDAO.SimpleDAO <MockSimpleObject>();
            dao.NullStringValue = null;
            dao.NullIntValue    = 0;
            dao.SimpleDelete(con, obj);
            con.Close();
        }
Exemplo n.º 8
0
        public void TestSimpleInsert()
        {
            MockSimpleObject obj = new MockSimpleObject();

            obj.CommonName = "testInsert";
            obj.CreateDate = DateTime.Today;
            obj.FullName   = "Test Insert";
            obj.Id         = 99;
            obj.Status     = 4;
            OleDbConnection con = new OleDbConnection(connectString);

            con.Open();
            SimpleDAO.SimpleDAO <MockSimpleObject> dao = new SimpleDAO.SimpleDAO <MockSimpleObject>();
            dao.SimpleInsert(con, obj);
            con.Close();
        }
Exemplo n.º 9
0
        public void TestSimpleInsert()
        {
            MockSimpleObject obj = new MockSimpleObject();

            obj.CommonName = "testInsert";
            obj.CreateDate = DateTime.Today;
            obj.FullName   = "Test Insert";
            obj.Id         = 99;
            obj.Status     = 4;
            //SqlConnection con = new SqlConnection(@"Data Source=(local);Initial Catalog=JPAS;User ID=jpas_user;Password=jpas2007");
            OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dev\SimpleDAO\SimpleDAOTest\SimpleDAO.mdb");

            con.Open();
            SimpleDAO.SimpleDAO <MockSimpleObject> dao = new SimpleDAO.SimpleDAO <MockSimpleObject>();
            dao.SimpleInsert(con, obj);
            con.Close();
        }
Exemplo n.º 10
0
 public void TestSimpleDelete()
 {
     MockSimpleObject obj = new MockSimpleObject();
     obj.Id = 99;
     /*obj.CommonName = "testInsert";
     obj.CreateDate = DateTime.Today;
     obj.FullName = "Test Insert";
     obj.Status = 4;*/
     //SqlConnection con = new SqlConnection(connectString);
     OleDbConnection con = new OleDbConnection(connectString);
     con.Open();
     SimpleDAO.SimpleDAO<MockSimpleObject> dao = new SimpleDAO.SimpleDAO<MockSimpleObject>();
     //dao.NullStringValue = null;
     //dao.NullIntValue = 0;
     //obj.CommonName = "testInsert";
     dao.SimpleDelete(con, obj);
     con.Close();
 }
Exemplo n.º 11
0
        public void TestSimpleSelectList()
        {
            MockSimpleObject obj = new MockSimpleObject();

            //obj.DBOrderBy = new Dictionary<string, bool>();
            //obj.DBOrderBy.Add("Status", true);
            obj.Status = 1;
            //obj.CommonName = "cn10%";
            OleDbConnection con = new OleDbConnection(connectString);

            con.Open();
            SimpleDAO.SimpleDAO <MockSimpleObject> dao = new SimpleDAO.SimpleDAO <MockSimpleObject>();
            dao.NullStringValue = null;
            dao.NullIntValue    = 0;
            List <MockSimpleObject> list = dao.SimpleSelectList(con, obj);

            con.Close();
            Assert.IsTrue(list.Count == 3);
        }
Exemplo n.º 12
0
        public void TestSimpleUpdate()
        {
            MockSimpleObject obj = new MockSimpleObject();

            string[] key = new string[] { "ID" };
            obj.DBUpdateKey = key;
            obj.Id          = 99;
            obj.CommonName  = "object1";
            obj.CreateDate  = DateTime.Now;
            obj.FullName    = "Object One";
            obj.Status      = 5;
//            SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=JPAS;User ID=jpas_user;Password=jpas2007");
            OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dev\SimpleDAO\SimpleDAOTest\SimpleDAO.mdb");

            con.Open();
            SimpleDAO.SimpleDAO <MockSimpleObject> dao = new SimpleDAO.SimpleDAO <MockSimpleObject>();
            dao.SimpleUpdate(con, obj);
            con.Close();
        }
Exemplo n.º 13
0
        public void TestSimpleSelectList()
        {
            MockSimpleObject obj = new MockSimpleObject();

            //obj.DBOrderBy = new Dictionary<string, bool>();
            //obj.DBOrderBy.Add("Status", true);
            obj.Status = 1;
            //obj.CommonName = "cn10%";
            //SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=JPAS;User ID=jpas_user;Password=jpas2007");
            OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dev\SimpleDAO\SimpleDAOTest\SimpleDAO.mdb");

            con.Open();
            SimpleDAO.SimpleDAO <MockSimpleObject> dao = new SimpleDAO.SimpleDAO <MockSimpleObject>();
            dao.NullStringValue = null;
            dao.NullIntValue    = 0;
            List <MockSimpleObject> list = dao.SimpleSelectList(con, obj);

            con.Close();
            Assert.IsTrue(list.Count == 3);
        }
Exemplo n.º 14
0
        public void TestSimpleSelect()
        {
            MockSimpleObject            obj   = new MockSimpleObject();
            Dictionary <string, string> props = new Dictionary <string, string>();

            props.Add("Id", null);
            props.Add("CommonName", null);
            props.Add("FullName", "full_name");
            obj.CommonName = null;
            obj.Id         = 5;

            //obj.FullName = string.Empty;
            //SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=JPAS;User ID=jpas_user;Password=jpas2007");
            OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dev\SimpleDAO\SimpleDAOTest\SimpleDAO.mdb");

            con.Open();
            SimpleDAO.SimpleDAO <MockSimpleObject> dao = new SimpleDAO.SimpleDAO <MockSimpleObject>();
            SimpleObject newObj = dao.SimpleSelect(con, obj, props);

            con.Close();
        }
Exemplo n.º 15
0
        public void TestSimpleDelete()
        {
            MockSimpleObject obj = new MockSimpleObject();

            obj.Id = 99;

            /*obj.CommonName = "testInsert";
             * obj.CreateDate = DateTime.Today;
             * obj.FullName = "Test Insert";
             * obj.Status = 4;*/
            //SqlConnection con = new SqlConnection(connectString);
            OleDbConnection con = new OleDbConnection(connectString);

            con.Open();
            SimpleDAO.SimpleDAO <MockSimpleObject> dao = new SimpleDAO.SimpleDAO <MockSimpleObject>();
            //dao.NullStringValue = null;
            //dao.NullIntValue = 0;
            //obj.CommonName = "testInsert";
            dao.SimpleDelete(con, obj);
            con.Close();
        }
Exemplo n.º 16
0
 public void TestSimpleUpdate()
 {
     MockSimpleObject obj = new MockSimpleObject();
     string[] key = new string[] { "ID" };
     //obj.DBUpdateKey = key;
     obj.Id = 99;
     obj.CommonName = "object1";
     obj.CreateDate = DateTime.Today;
     obj.FullName = "Object One";
     obj.Status = 1;
     OleDbConnection con = new OleDbConnection(connectString);
     con.Open();
     SimpleDAO.SimpleDAO<MockSimpleObject> dao = new SimpleDAO.SimpleDAO<MockSimpleObject>();
     Dictionary<string, string> props = new Dictionary<string, string>();
     props.Add("Id", "ID");
     props.Add("CommonName", "COMMON_NAME");
     props.Add("FullName", "FULL_NAME");
     props.Add("Status", "STATUS");
     dao.SimpleUpdate(con, obj); //, props);
     con.Close();
     Assert.Inconclusive("nothing to assert");
 }
Exemplo n.º 17
0
 public void TestSimpleUpdate()
 {
     MockSimpleObject obj = new MockSimpleObject();
     string[] key = new string[] { "ID" };
     obj.DBUpdateKey = key;
     obj.Id = 99;
     obj.CommonName = "object1";
     obj.CreateDate = DateTime.Now;
     obj.FullName = "Object One";
     obj.Status = 5;
     //            SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=JPAS;User ID=jpas_user;Password=jpas2007");
     OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dev\SimpleDAO\SimpleDAOTest\SimpleDAO.mdb");
     con.Open();
     SimpleDAO.SimpleDAO<MockSimpleObject> dao = new SimpleDAO.SimpleDAO<MockSimpleObject>();
     dao.SimpleUpdate(con, obj);
     con.Close();
 }
Exemplo n.º 18
0
        public void TestSimpleSelectWithSQL()
        {
            MockSimpleObject criteria = new MockSimpleObject();
            criteria.Id = 5;
            criteria.DBTable = "SELECT * FROM MOCK_SIMPLE WHERE ID= @Id AND COMMON_NAME=@CommonName AND FULL_NAME =@FullName";
            //obj.DBTable = "SELECT * FROM SOME_TABLE WHERE ID= ? AND COMMON_NAME=? AND FULL_NAME =? AND COL3=?";
            OleDbConnection con = new OleDbConnection(connectString);
            con.Open();
            SimpleDAO.SimpleDAO<MockSimpleObject> dao = new SimpleDAO.SimpleDAO<MockSimpleObject>();
            MockSimpleObject newObj = dao.SimpleSelect(con, criteria);
            Assert.AreEqual(criteria.Id, newObj.Id);
            newObj = null;

            Dictionary<string, string> props = new Dictionary<string, string>();
            props.Add("Id", null);
            props.Add("CommonName", null);
            props.Add("FullName", "full_name");
            newObj = dao.SimpleSelect(con, criteria, props);
            con.Close();
            Assert.AreEqual(newObj.Id, 5);
            con.Close();
        }
Exemplo n.º 19
0
        public void TestSimpleSelectList()
        {
            MockSimpleObject obj = new MockSimpleObject();
            //obj.DBOrderBy = new Dictionary<string, bool>();
            //obj.DBOrderBy.Add("Status", true);
            obj.Status = 1;
            //obj.CommonName = "cn10%";
            OleDbConnection con = new OleDbConnection(connectString);

            con.Open();
            SimpleDAO.SimpleDAO<MockSimpleObject> dao = new SimpleDAO.SimpleDAO<MockSimpleObject>();
            dao.NullStringValue = null;
            dao.NullIntValue = 0;
            List<MockSimpleObject> list = dao.SimpleSelectList(con, obj);
            con.Close();
            Assert.IsTrue(list.Count == 3);
        }
Exemplo n.º 20
0
        public void TestSimpleSelect()
        {
            MockSimpleObject criteria = new MockSimpleObject();
            criteria.Id = 5;
            OleDbConnection con = new OleDbConnection(connectString);
            //OracleConnection con = new OracleConnection(connectString);
            con.Open();
            SimpleDAO.SimpleDAO<MockSimpleObject> dao = new SimpleDAO.SimpleDAO<MockSimpleObject>(':');

            MockSimpleObject newObj = dao.SimpleSelect(con, criteria);
            Assert.AreEqual(newObj.Id, 5);
            newObj = null;

            Dictionary<string, string> props = new Dictionary<string, string>();
            props.Add("Id", null);
            props.Add("CommonName", null);
            props.Add("FullName", "FULL_NAME");
            newObj = dao.SimpleSelect(con, criteria, props);
            con.Close();
            Assert.AreEqual(newObj.Id, 5);
        }
Exemplo n.º 21
0
        public void TestSimpleSelect()
        {
            MockSimpleObject obj = new MockSimpleObject();
            Dictionary<string, string> props = new Dictionary<string, string>();
            props.Add("Id", null);
            props.Add("CommonName", null);
            props.Add("FullName", "full_name");
            obj.CommonName = null;
            obj.Id = 5;

            //obj.FullName = string.Empty;
            //SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=JPAS;User ID=jpas_user;Password=jpas2007");
            OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dev\SimpleDAO\SimpleDAOTest\SimpleDAO.mdb");
            con.Open();
            SimpleDAO.SimpleDAO<MockSimpleObject> dao = new SimpleDAO.SimpleDAO<MockSimpleObject>();
            SimpleObject newObj = dao.SimpleSelect(con, obj,props);
            con.Close();
        }
Exemplo n.º 22
0
 public void TestSimpleInsert()
 {
     MockSimpleObject obj = new MockSimpleObject();
     obj.CommonName = "testInsert";
     obj.CreateDate = DateTime.Today;
     obj.FullName = "Test Insert";
     obj.Id = 99;
     obj.Status = 4;
     OleDbConnection con = new OleDbConnection(connectString);
     con.Open();
     SimpleDAO.SimpleDAO<MockSimpleObject> dao = new SimpleDAO.SimpleDAO<MockSimpleObject>();
     dao.SimpleInsert(con, obj);
     con.Close();
 }
Exemplo n.º 23
0
 public void GetDBUpdateKeysTest()
 {
     MockSimpleObject obj = new MockSimpleObject();
     string[] expected = new string[] { "MOCK_SIMPLE_ID" };
     string[] actual = ReflectionUtils.InferDBUpdateKeys(obj);
     Assert.AreEqual(expected[0], actual[0]);
 }
Exemplo n.º 24
0
        public void TestSimpleSelectList()
        {
            MockSimpleObject obj = new MockSimpleObject();
            //obj.DBOrderBy = new Dictionary<string, bool>();
            //obj.DBOrderBy.Add("Status", true);
            obj.Status = 1;
            //obj.CommonName = "cn10%";
            //SqlConnection con = new SqlConnection("Data Source=(local);Initial Catalog=JPAS;User ID=jpas_user;Password=jpas2007");
            OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\dev\SimpleDAO\SimpleDAOTest\SimpleDAO.mdb");

            con.Open();
            SimpleDAO.SimpleDAO<MockSimpleObject> dao = new SimpleDAO.SimpleDAO<MockSimpleObject>();
            dao.NullStringValue = null;
            dao.NullIntValue = 0;
            List<MockSimpleObject> list = dao.SimpleSelectList(con, obj);
            con.Close();
            Assert.IsTrue(list.Count == 3);
        }