Click here to Skip to main content
12,896,953 members (52,050 online)
Click here to Skip to main content


50 bookmarked
Posted 23 Oct 2008

From Mocks to Isolation

, 31 Oct 2008 CPOL
The article discusses how to isolate the code under test from behavior of referenced classes by using mocking frameworks.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using NUnit.Framework;

using Customers;

namespace UnitTests
    public class CarInsuranceTest1_Integration
        public void GetCustomerPriceGroup_Adult()
            var dataLayer = new DataLayer();
            int customerID = dataLayer.CreateCustomer("John", "Smith", new DateTime(1970, 1, 1, 0, 0, 0));

            var carInsurance = new CarInsurance();
            PriceGroup priceGroup = carInsurance.GetCustomerPriceGroup(customerID);
            Assert.AreEqual(PriceGroup.Adult, priceGroup, "Incorrect price group");

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


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


About the Author

Vagif Abilov
Architect Miles AS
Norway Norway
Vagif Abilov is a Russian/Norwegian software developer and architect working for Miles. He has more than twenty years of programming experience that includes various programming languages, currently using mostly C# and F#.

Vagif writes articles and speaks at user group sessions and conferences. He is a contributor and maintainer of several open source projects, including Simple.Data OData adapter, Simple.OData.Client and MongOData.

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 31 Oct 2008
Article Copyright 2008 by Vagif Abilov
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid