Click here to Skip to main content
14,977,402 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am in the process to design architecture for mvc based project. For better approach i want to use TDD (using NUnit framework) pattern. I have fallowing layers in project.

MVC Project
Application Service layer.
Domain Service layer
Infrastructure layer
Function calls will be executed same way as numbering for layers. I want to use TDD concept from 'Application Service layer' (Not from controllers of MVC). First of all tell me is it right way to use TDD from layers other than MVC.& secondly I am confused that if I am going with this way, how i will make call to application layer functions for crud operations as application layer functions have internal calls to domain service layer functions for crud operations.I tried by giving direct call to application layer functions by creating its class object but it is giving error that object reference not set to instance of object.

My code is
using ApplicationServices.AppServiceInterfaces;
using ApplicationServices.AppServiceClasses;
using PeocitEntities.MasterEntities;

 namespace MyUnitTest
public class Account_Group
    AccountGroupApplnService accApplicationServiceObject;

    public void SetupTest()
        accApplicationServiceObject = new AccountGroupApplnService();//Here iam getting error

    public void AddAccountGroup()

        AccountGroup accountGroupObj = new AccountGroup();

        accountGroupObj.strName = "Test TDD Group";
        accountGroupObj.intGroupType = 10;
        accountGroupObj.groupType_name = Enum.GetName(typeof(EnumTypelib.glAccountGroupTypes), accountGroupObj.intGroupType);
        accountGroupObj.intPrimaryGroup = (int)EnumTypelib.PrimaryGroupType.as_liabilities;
        bool IsGroupAccountCreated = accApplicationServiceObject.CreateAccountGroup(accountGroupObj);//Internally calls service & then infra layer.

    public void TearDownTest()
        accApplicationServiceObject = null;

My question is how to use TDD(with Nunit) for application having multiple layers?Or is there is any other way to perform this task(Option to TDD)?

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