Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

How do i unit testing, if i have this:

I wrote code about this: Have "customer", need find customers, that have same name, address, or phone(they can be 2 and more) , then need choose from them 2 customers, and merge them both(second customers will be deleted from db, but them property will attach to customer, that already was merged.)

Now i want check , if others customers deleted from db, them property(account,surname, and etc.) was attach to merged customer or no?

C#
public int MergeCustomer(Customer customer, int deletedCustomerID){
}

_db.SaveChanges();
 scope.Complete();



Thank you for help.
Posted
Updated 15-Aug-14 4:19am
v4

plaese see here. I think it may helps You
http://msdn.microsoft.com/en-us/library/hh270865.aspx[^]
 
Share this answer
 
v3
NUnit is quite good. The test runner is easy to use. See this article,
Unit Testing Using NUnit[^]
 
Share this answer
 
You've chosen a difficult section, the data layer to want to test.
Generally you will have to design for testability, specifically having a datamanager class which does the logics and have some protected method for just storing and readling e.g. then you can derive that class and implement a ram instance for your unit testing purposes.

This describes the principles in play and it what you need to make your own practice before you can begin to mock out data layer components.
http://msdn.microsoft.com/en-us/magazine/dd263069.aspx[^]

another aspect is the ability to 'mock out' certain calls (alternatively) here a lot of provider ways are available but see a good article here http://www.codeproject.com/Articles/686935/Unit-testing-with-Mock-objects-Rhino-Mocks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900