Click here to Skip to main content
14,328,801 members
Rate this:
Please Sign up or sign in to vote.
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?

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

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



Thank you for help.
Posted
Updated 15-Aug-14 4:19am
v4
Rate this:
Please Sign up or sign in to vote.

Solution 1

plaese see here. I think it may helps You
http://msdn.microsoft.com/en-us/library/hh270865.aspx[^]
   
v3
Rate this:
Please Sign up or sign in to vote.

Solution 2

NUnit is quite good. The test runner is easy to use. See this article,
Unit Testing Using NUnit[^]
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

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
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100