Click here to Skip to main content
13,193,064 members (63,672 online)
Rate this:
Please Sign up or sign in to vote.

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,
Posted 3-Feb-13 7:07am
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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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[^].

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171017.2 | Last Updated 3 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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