Click here to Skip to main content
15,886,038 members
Articles / Database Development / SQL Server / SQL Server 2008

Simple Data Access in C#

Rate me:
Please Sign up or sign in to vote.
4.11/5 (15 votes)
11 Jan 2009CPOL5 min read 83.7K   1.4K   58  
Fast and easy to use data access class library.
using System;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using Yap.Data.Client;


namespace Yap.Data.UnitTest
{
	[TestClass]
	public class FieldTestFixture
	{
		[TestMethod]
		[ExpectedException(typeof(ArgumentNullException))]
		public void Constructor_NameIsEmpty_ThrowArgumentNullException()
		{
			new Field(String.Empty, typeof(Int32));
		}

		[TestMethod]
		[ExpectedException(typeof(ArgumentNullException))]
		public void Constructor_TypeIsNull_ThrowArgumentNullException()
		{
			new Field("an field", null);
		}

		[TestMethod]
		public void Equals_OtherIsNull_ReturnFalse()
		{
			var field = new Field("an field", typeof(Int32));
			Assert.IsFalse(field.Equals(null), "Equals() with null should return false.");
		}

		[TestMethod]
		public void Equals_FullTest()
		{
			var one = new Field("an field", typeof(Int32));
			var another = new Field("an field", typeof(Int32));
			Assert.AreEqual(one, another, "Equals() with equal field should return true.");
			one = new Field("another field", typeof(Int32));
			Assert.AreNotEqual(one, another, "Equals() with not equal field should return false.");
		}

		[TestMethod]
		public void ToString__ShouldBeEqualToName()
		{
			var field = new Field("an field", typeof(Int32));
			Assert.AreEqual(field.Name, field.ToString(), "ToString() should be equal to Field.Name.");
		}

		[TestMethod]
		public void GetHashCode__ShouldBeEqualToNameGetHashCode()
		{
			var field = new Field("an field", typeof(Int32));
			Assert.AreEqual(field.Name.GetHashCode(), field.GetHashCode(), "GetHashCode() should be equal to Field.Name.GetHashCode().");
		}
	}
}

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


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

Comments and Discussions