McKelt.com

Remembering Thoughts

 

Recent comments

Authors

Categories


Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010

Context Specification

namespace Example
{
    using System;

    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using Rhino.Mocks;

    public abstract class ContextSpecification<T>
    {
        protected Exception executionException;

        protected T sut { get; set; }

        [TestInitialize]
        public void Start()
        {
            this.Context();
            this.SetupMockResults();
            this.Because();
        }

        [TestCleanup]
        public void CleanUp()
        {
            this.Clean();
        }

        protected virtual void Context()
        {
        }

        protected virtual void SetupMockResults()
        {
        }

        protected virtual void Because()
        {
        }

        protected virtual void Clean()
        {
        }

        protected TInterface GetDependency<TInterface>() where TInterface : class
        {
            return MockRepository.GenerateMock<TInterface>();
        }

        public void Execute(Action action)
        {
            try
            {
                action();
            }
            catch (Exception ex)
            {
                executionException = ex;
            }
        }

    }
}

Posted by chris on Monday, October 12, 2009 1:48 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading