Click here to Skip to main content
15,892,809 members
Articles / Programming Languages / C#

TILO - An Automated Unit-Testing Tool for C and C++

,
Rate me:
Please Sign up or sign in to vote.
4.57/5 (10 votes)
27 Aug 20056 min read 47.9K   936   45  
Tilo is a program / tool designed to help developers in creating and running unit tests. Unit tests will have to be coded, not written, and will be executed automatically by the tool.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace TiloGUI
{
	/// <summary>
	/// Summary description for DlgAddModuleToProject.
	/// </summary>
	public class DlgAddModuleToProject : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox1;
		private System.Windows.Forms.Button btnOK;
		private System.Windows.Forms.Button btnCancel;
		private System.Windows.Forms.Label lblModuleName;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox edModuleName;
		private System.Windows.Forms.TextBox edDllPath;
		private System.Windows.Forms.Button btnBrowse;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		/// <summary>
		/// We store the name of the module, as the user typed it, in this variable
		/// </summary>
		private string m_strModuleName;

		/// <summary>
		/// We store the path to the DLL in this variable
		/// </summary>
		private string m_strDllPath;

		/// <summary>
		/// The name of the module
		/// </summary>
		public string ModuleName
		{
			get
			{
				return m_strModuleName;
			}
		}

		/// <summary>
		/// The path to the DLL
		/// </summary>
		public string DllPath
		{
			get
			{
				return m_strDllPath;
			}
		}

		public DlgAddModuleToProject()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.groupBox1 = new System.Windows.Forms.GroupBox();
			this.btnBrowse = new System.Windows.Forms.Button();
			this.edModuleName = new System.Windows.Forms.TextBox();
			this.lblModuleName = new System.Windows.Forms.Label();
			this.label1 = new System.Windows.Forms.Label();
			this.edDllPath = new System.Windows.Forms.TextBox();
			this.btnOK = new System.Windows.Forms.Button();
			this.btnCancel = new System.Windows.Forms.Button();
			this.groupBox1.SuspendLayout();
			this.SuspendLayout();
			// 
			// groupBox1
			// 
			this.groupBox1.Controls.Add(this.btnBrowse);
			this.groupBox1.Controls.Add(this.edModuleName);
			this.groupBox1.Controls.Add(this.lblModuleName);
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Controls.Add(this.edDllPath);
			this.groupBox1.Location = new System.Drawing.Point(7, 5);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new System.Drawing.Size(429, 75);
			this.groupBox1.TabIndex = 0;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Specify module information";
			// 
			// btnBrowse
			// 
			this.btnBrowse.Location = new System.Drawing.Point(347, 42);
			this.btnBrowse.Name = "btnBrowse";
			this.btnBrowse.Size = new System.Drawing.Size(66, 23);
			this.btnBrowse.TabIndex = 4;
			this.btnBrowse.Text = "&Browse...";
			this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click);
			// 
			// edModuleName
			// 
			this.edModuleName.Location = new System.Drawing.Point(92, 17);
			this.edModuleName.Name = "edModuleName";
			this.edModuleName.Size = new System.Drawing.Size(321, 20);
			this.edModuleName.TabIndex = 1;
			this.edModuleName.Text = "[New module]";
			// 
			// lblModuleName
			// 
			this.lblModuleName.AutoSize = true;
			this.lblModuleName.Location = new System.Drawing.Point(8, 19);
			this.lblModuleName.Name = "lblModuleName";
			this.lblModuleName.Size = new System.Drawing.Size(78, 16);
			this.lblModuleName.TabIndex = 0;
			this.lblModuleName.Text = "Module &Name:";
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.Location = new System.Drawing.Point(8, 45);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(76, 16);
			this.label1.TabIndex = 2;
			this.label1.Text = "DLL File &Path:";
			// 
			// edDllPath
			// 
			this.edDllPath.Location = new System.Drawing.Point(92, 43);
			this.edDllPath.Name = "edDllPath";
			this.edDllPath.Size = new System.Drawing.Size(248, 20);
			this.edDllPath.TabIndex = 3;
			this.edDllPath.Text = "";
			// 
			// btnOK
			// 
			this.btnOK.Location = new System.Drawing.Point(264, 88);
			this.btnOK.Name = "btnOK";
			this.btnOK.TabIndex = 1;
			this.btnOK.Text = "OK";
			this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
			// 
			// btnCancel
			// 
			this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.btnCancel.Location = new System.Drawing.Point(356, 88);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.TabIndex = 2;
			this.btnCancel.Text = "Cancel";
			// 
			// DlgAddModuleToProject
			// 
			this.AcceptButton = this.btnOK;
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.CancelButton = this.btnCancel;
			this.ClientSize = new System.Drawing.Size(442, 117);
			this.ControlBox = false;
			this.Controls.Add(this.btnOK);
			this.Controls.Add(this.groupBox1);
			this.Controls.Add(this.btnCancel);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "DlgAddModuleToProject";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Add Module to Project";
			this.groupBox1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void btnOK_Click(object sender, System.EventArgs e)
		{
			// Check module name is there
			if (edModuleName.Text.Trim () == "")
			{
				MessageShow.ShowError ("Please type a name for the module.");
				edModuleName.SelectAll ();
				edModuleName.Focus ();
				return;
			}
			m_strModuleName = edModuleName.Text.Trim ();
			// Check DLL path is there
			if (edDllPath.Text.Trim () == "")
			{
				MessageShow.ShowError ("Please type or browse to a DLL file associated with the module.");
				edDllPath.SelectAll ();
				edDllPath.Focus ();
				return;
			}
			m_strDllPath = edDllPath.Text.Trim ();
			// OK
			DialogResult = DialogResult.OK;
		}

		private void btnBrowse_Click(object sender, System.EventArgs e)
		{
			using (OpenFileDialog dlg = new OpenFileDialog ())
			{
				dlg.Filter = "DLL files (*.dll)|*.dll";
				if (dlg.ShowDialog (this) == DialogResult.OK)
					edDllPath.Text = dlg.FileName;
			}
		}
	}
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Written By
Cyprus Cyprus
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions