darma teja

darma teja

  • NA
  • 496
  • 336.6k

How to write unittest for database classes?

Dec 14 2017 4:53 AM
  1. public bool insertCustomer(Customer newCustomer)  
  2.   {  
  3. bool inserted =false;  
  4. SqlCommand cmd=new SqlCommand();  
  5. cmd.CommandText= "insert into Customer (name, firstname, address) values (@name, @firstname, @address)";  
  6. cmd.Parameters.add(new SqlParameter("@name",Customer.name));  
  7. cmd.Parameters.add(new SqlParameter("@firstname",Customer.firstname));  
  8. cmd.Parameters.add(new SqlParameter("@address",Customer.address));  
  9.   
  10. // executes command here and it returns new ID  isnsterted= true;  
  11.   
  12. return inserted ;  
  13.   } 

Answers (1)