NUnitForms GenericControlTester

written by Ryan Olshan on Thursday, May 01 2008

In a Windows forms test project using NUnitForms, I was trying to test some DevExpress controls, so I came up with the GenericControlTester for this. It can test any control as long as it inherits System.Windows.Forms.Control.

using System.Windows.Forms;

using NUnit.Extensions.Forms;

 

    public class GenericControlTester<T> : ControlTester where T : Control

    {

        public GenericControlTester(ControlTester tester, int index) : base(tester, index)

        {

        }

 

        public GenericControlTester(string name) : base(name)

        {

        }

 

        public GenericControlTester(string name, Form form) : base(name, form)

        {

        }

 

        public GenericControlTester(string name, string formName) : base(name, formName)

        {

        }

 

        new public GenericControlTester<T> this[int index]

        {

            get { return new GenericControlTester<T>(this, index); }

        }

 

        public T Properties

        {

            get { return (T)Control; }

        }

    }

Similar Posts

  1. Unit testing events with anonymous methods
  2. IEnumerable<> and IEnumerable
  3. Implicit and Explicit Operators in C#

Post a comment