Beispiel #1
0
		/// <summary>Begin TestCase
		/// <param name="Description">TestCase Description, used on logs</param>
		/// </summary>
		public void BeginCase(string Description)
		{
			//init the new TestCase with Unique TestCase Number and Description
			_testCase = new UniqueId(Description);

			if(this._logOnSuccess == true)
				Log(string.Format("Starting Case: [{0}]", _testCase.ToString()));
		}
Beispiel #2
0
		/// <summary>Compare two objects (using Object.Equals)
		/// </summary>
		protected bool Compare(object a, object b)
		{
			//signal that the Compare method has been called
			if (_testCase == null) {
				_testCase = new UniqueId(_testName);
			}
			this._testCase.CompareInvoked = true;
			//a string that holds the description of the objects for log
			string ObjectData;

			//check if one of the objects is null
			if  (a == null && b != null)
			{
				ObjectData = "Object a = null" + ", Object b.ToString() = '" + b.ToString() + "'(" + b.GetType().FullName + ")";
				this._testCase.Success = false; //objects are different, TestCase Failed
				LogCompareResult(ObjectData);
				return this._testCase.Success;
			}

			//check if the other object is null
			if  (a != null && b == null)
			{
				ObjectData = "Object a.ToString() = '" + a.ToString() + "'(" + a.GetType().FullName + "), Object b = null";
				this._testCase.Success = false; //objects are different, TestCase Failed
				LogCompareResult(ObjectData);
				return this._testCase.Success;
			}

			//check if both objects are null
			if ( (a == null && b == null) )
			{
				ObjectData = "Object a = null, Object b = null";
				this._testCase.Success = true; //both objects are null, TestCase Succeed
				LogCompareResult(ObjectData);
				return this._testCase.Success;
			}

			ObjectData = "Object a.ToString() = '" + a.ToString() + "'(" + a.GetType().FullName + "), Object b.ToString = '" + b.ToString() + "'(" + b.GetType().FullName + ")";
			//use Object.Equals to compare the objects
			this._testCase.Success = (a.Equals(b));
			LogCompareResult(ObjectData);
			return this._testCase.Success;
		}