Click here to Skip to main content
15,886,689 members
Articles / Programming Languages / C#

An NUnit Test Suite Implementation

Rate me:
Please Sign up or sign in to vote.
4.89/5 (10 votes)
26 Aug 2006Public Domain8 min read 63.4K   372   58  
This article describes a scalable NUnit unit test suite for use on a tiered, database-driven .NET application.
namespace BLL {

public class Client : PersistentObject {
    private string _firstName = null;
    private string _lastName = null;
    private string _middleName = null;
    private long _addressUID = long.MinValue;

    private Address _addressObject;

    public string FirstName {
        get { return _firstName; }
        set { _firstName = value; }
    }

    public string LastName {
        get { return _lastName; }
        set { _lastName = value; }
    }

    public string MiddleName {
        get { return _middleName; }
        set { _middleName = value; }
    }

    public long AddressUID {
        get { return _addressUID; }
        set { _addressUID = value; }
    }

    /// <summary>
    /// On-demand property that returns this Client's Address based on the 
    /// current value of AddressUID
    /// </summary>
    public Address Address {
        get {
            if (AddressUID == long.MinValue) {
                _addressObject = null;
            }
            else if (_addressObject == null || AddressUID != _addressObject.UID) {
                _addressObject = new Address();
                _addressObject.Fill(AddressUID);
            }
            return _addressObject;
        }
    }

    public override void Save() {
        // Call DAL to save fields
        // ...
    }
    public override void Fill(long uid) {
        // Call DAL to fill fields
        // ...
    }
    public override void Delete() {
        // Call DAL to delete object
        // ...
    }

    /// <summary>
    /// Utility function that returns the Client with the given UID
    /// </summary>
    public static Client Fetch(long clientUID) {
        return PersistentObject.Fetch<Client>(clientUID);
    }
}
}

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.

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication


Written By
Web Developer
United States United States
Brett Daniel is a graduate computer science student at the University of Illinois Urbana-Champaign. His work focuses on software engineering, application architecture, software testing, and programming languages.

Comments and Discussions