SnCore!

Writing Unit Tests

Introduction

This page will guide you through the SnCore unit testing. SnCore has almost 100% unit test coverage, which ensures stable product evolution.

Prerequisites

  • NUnit 2.2

Running Unit Tests

  1. Run nunit/bin/nunit-gui.exe.
  2. Open the SnCore.nunit project.
  3. Run.

Writing Unit Tests

SnCore unit tests live in the following assemblies:
  • SnCore.Tools.Tests: utility functions tests
  • SnCore.Data.Tests: straightforward N-Hibernate mappings
  • SnCore.Services.Tests: low-level business logic tests
  • SnCore.BackEnd.Tests: back-end services tests
  • SnCore.Web.Tests: generic website tests
  • SnCore.WebServices.Tests: elementary web services tests
  • SnCore.Web.Soap.Tests: detailed SOAP interface layer tests
  • SnCore.Stress.Tests: performance tests
To write a new set of unit tests, create a class that inherits SnCore::Data::Tests::NHibernateTest. This gives you access to an NHibernate Session object to run database operations. Use [TestFixure] and [Test] attributes to mark test classes and unit tests.

using System;
using NUnit.Framework;
using SnCore.Data;
using NHibernate;
using SnCore.Data.Tests;
using System.Collections;
using NHibernate.Expression;

namespace SnCore.Services.Tests
{
    [TestFixture]
    public class ManagedMyClassTest : NHibernateTest
    {
        public ManagedMyClassTest()
        {

        }

        [Test]
        public void CreateMyClass()
        {
            MyClass class = new MyClass(Session);
            try
            {
                class.CreateOrUpdate();
            }
            finally
            {
                if (class.Id > 0)
                {
                    class.Delete();
                }
            }
        }
    }
}
© Vestris Inc., 2006-2007, All Rights Reserved | SnCore | Mon Mar 3 08:58:17 2008 | Doxygen 1.5.4