示例#1
0
        public static void TestInsert(SqlMapper_v1.IDataMapper <Product> prodMapper)
        {
            Product newprod = new Product("benfas", "10", 12, 20, 0);

            prodMapper.Insert(newprod);
            UnitTest.TestGetAll(prodMapper); //vejo estado actual
        }
示例#2
0
        public static void TestGetAll(SqlMapper_v1.IDataMapper <Product> prodMapper)
        {
            IEnumerable <Product> prods = prodMapper.GetAll();

            foreach (Product p in prods)
            {
                Console.WriteLine(p.ToString());
            }
            Console.ReadKey();
        }
示例#3
0
        public static void TestUpdate(SqlMapper_v1.IDataMapper <Product> prodMapper)
        {
            //UnitTest.TestGetAll(prodMapper); //vejo estado actual
            Product newprod = new Product(1, "NN", "10", 12, 20, 0);

            prodMapper.Update(newprod);
            Console.WriteLine("------------------> Alterei um registo");
            UnitTest.TestGetAll(prodMapper); //vejo estado actual
            newprod = new Product(1, "Batata", "5", 5, 25, 15);
            prodMapper.Update(newprod);
            Console.WriteLine("------------------> Repus o estado do registo");
            UnitTest.TestGetAll(prodMapper); //vejo estado actual
        }
示例#4
0
        public static void TestDelete(SqlMapper_v1.IDataMapper <Product> prodMapper)
        {
            Console.WriteLine("------------------> Inseri um registo");
            UnitTest.TestInsert(prodMapper); //insiro registo
            SqlMapper_v1.DataMapper <Product> prodMapper2 = (SqlMapper_v1.DataMapper <Product>)prodMapper;
            int lastRecord = prodMapper2.GetLastInsertedRecord();

            Console.WriteLine("------------------> Inseri um registo");
            UnitTest.TestInsert(prodMapper); //insiro registo
            Product newprod = new Product(lastRecord, "", "", 0, 0, 0);

            prodMapper.Delete(newprod);
            Console.WriteLine("------------------> Removi um registo");
            newprod = new Product(lastRecord + 1, "", "", 0, 0, 0);
            prodMapper.Delete(newprod);
            Console.WriteLine("------------------> Removi um registo");
            UnitTest.TestGetAll(prodMapper); //vejo estado actual
        }