download MyTestAssertHelper.cs
Language: C#
License: MSVSSDK
LOC: 31
Project Info
C# Example.MyTestTypeSample
Server: Visual Studio SDK
Type: filesystem
...xtensibility\MyTest\MyTest\
   assembly.cs
   MyHostAdapter.cs
   ...pterRunConfigControl.cs
   ...nfigControl.Designer.cs
   ...erRunConfigControl.resx
   MyTest.cs
   MyTest.csproj
   MyTestAdapter.cs
   MyTestAssertHelper.cs
   MyTestEditorControl.cs
   ...itorControl.Designer.cs
   MyTestEditorControl.resx
   MyTestEditorFactory.cs
   MyTestPackage.cs
   MyTestResourceIds.cs
   MyTestResult.cs
   MyTestResultViewControl.cs
   ...ViewControl.designer.cs
   ...tResultViewControl.resx
   MyTestResultViewWindow.cs
   MyTestRunConfigControl.cs
   ...nfigControl.Designer.cs
   ...stRunConfigControl.resx
   MyTestTip.cs
   MyTestTuip.cs
   MyTestWizard.cs

/***************************************************************************
 
Copyright (c) Microsoft Corporation. All rights reserved.
This code is licensed under the Visual Studio SDK license terms.
THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
 
***************************************************************************/
//*************************************************************************************************
// MyTestAssertHelper.cs
//
// This file defines the MyTestAsserHelper class, providing assertion helpers
//
// Copyright(c) Microsoft Corporation, 2005
//*************************************************************************************************

using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.VisualStudio.TestTools.Samples
{
	/// <summary>
	/// Provides a wrapper for assertions and exception throwning for simplicity
	/// </summary>
	internal sealed class MyTestAssertHelper
	{
		/// <summary>
		/// Checks if a supplied parameter is vaild
		/// </summary>
		/// <exception cref="ArgumentNullException">Throws if "parameter" is null</exception>
		/// <param name="parameter">The paramter to check for Null-ness</param>
		/// <param name="parameterName">The name of the parameter that is being checked</param>
		internal static void ParameterNotNull(object parameter, string parameterName)
		{
			Debug.Assert(parameter != null);
			Debug.Assert(!String.IsNullOrEmpty(parameterName));

			if (parameter == null)
				throw new ArgumentNullException(parameterName);
		}

		/// <summary>
		/// Checks if a supplied string variable is empty/null and throws appropriately
		/// </summary>
		/// <exception cref="ArgumentNullException">Throws if "parameter" is null or empty</exception>
		/// <param name="parameter">The parameter to check for Empty/Null-ness</param>
		/// <param name="parameterName">Name of the parameter being checked</param>
		internal static void StringNotNullOrEmpty(string parameter, string parameterName)
		{
			Debug.Assert(!String.IsNullOrEmpty(parameter));
			Debug.Assert(!String.IsNullOrEmpty(parameterName));

			if(String.IsNullOrEmpty(parameter))
				throw new ArgumentException(Properties.Resources.Assert_CannotBeNullOrEmpty, parameterName);
		}

		/// <summary>
		/// Checks an array for nullness and Zero-Length
		/// </summary>
		/// <exception cref="ArgumentNullException">Throws if "parameter" is null</exception>
		/// <param name="parameter">Array to check for Zero-Length & Null-ness</param>
		/// <param name="parameterName">Name of the parameter being checked</param>
		internal static void ArrayNotNullOrEmpty(object[] parameter, string parameterName)
		{
			Debug.Assert((parameter != null) && (parameter.Length != 0));
			Debug.Assert(!String.IsNullOrEmpty(parameterName));

			if ((parameter == null) || (parameter.Length == 0))
				throw new ArgumentException(Properties.Resources.Assert_CannotBeNullOrEmpty, parameterName);
		}
	}
}

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us