Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hey,

I've posted about this application before and had some good responses, so hopefully you guys can help again.

I'm currently undertaking my final year of a Computer Science degree in the UK, and building an ASP.NET Web Forms CMS with an E-Commerce module as my final project.

I'm using N-Tier architecture, and used a few tutorials from here to create an Entities Layer, Data Access Layer, Business Logic Layer and Presentation Layer.

I'm looking in to unit testing the BLL to start with, but didn't use an ORM for the DAL, so I'm having trouble trying to cut out the database dependencies with a mocking framework.

An example flow of information through my App:

->Presentation calls the BLL GetProducts() method.

->BLL calls the DAL GetProducts() method which returns a list of product entities.

->DAL GetProducts method creates a list of product entities from the GetProductList() stored procedure in the database.

How would you go about unit testing the BLL, and integration testing the DAL? I'd rather not switch out to using an ORM such as EF or NHibernate as I produced a lot of documentation on the architecture that is being used so far, and any major changes would mean a lot more documentation to be written.

The majority of online information seems to be combining Moq with EF and MVC4.

Thanks in advance,
Stu.
Posted
Comments
Kishor Deshpande 3-Feb-13 21:49pm    
So, basically you are trying to build a n-layer application in which you have DAL, BAL and Presentation layers separated.

n- tier means you have your presentation at a separate server probably a web server, Database at another and Web Services deployed on separate machine.

Hi,
MSTest comes with Visual studio which is testing framework.
Now, when you think about isolation framework to remove external dependencies, most of the developers use Rhino Mocks.
If you really want to learn how you can write Unit tests for your BAL code without changing it to OR/M,
The best reference book is: The Art of Unit Testing
with Examples in .NET
by Roy Osherove
 
Share this answer
 
For unit testing the BLL, you can always consider using the Microsoft Visual Studio Testing Framework or a third party like Nunint.
For a mocking framework, you can consider using Moles[^].
 
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