Archive for Gennaio 24th, 2008

Unit Test Wrapper

CodeKeep C# Feed Gennaio 24th, 2008

Description: Quickly implemented wrapper class, used to keep unit tests within the same transaction scope.

Link: http://www.codekeep.net/snippets/09731b8b-1d24-49c1-8a6d-71bbc102e5d3.aspx

	[TestFixture]
	public abstract class AbstractDaoTest
	{
		public static DateTime TestDate
		{
			get { return DateTime.Now; }
		}

		private TransactionScope trans;

		protected TransactionOptions transactionOptions;

		protected abstract void TestInitialize();

		protected abstract void Cleanup();

		[TestFixtureSetUp]
		public void BaseSetup()
		{

			transactionOptions = new TransactionOptions();

			transactionOptions.IsolationLevel = IsolationLevel.Serializable;

			trans = new TransactionScope(TransactionScopeOption.Required, transactionOptions);

			TestInitialize();

		}

		[TestFixtureTearDown]
		public void BaseCleanup()
		{
			trans.Dispose();
			Cleanup();
		}

	}

Stringa di formattazione importo

CodeKeep C# Feed Gennaio 24th, 2008

Description: Stringa di formattazione per importi con indicazione del segno e due decimali

Link: http://www.codekeep.net/snippets/35323d91-9a37-44d3-8a33-f11528890ea4.aspx

saldoFin.ToString("+#,0.00;-#,0.00;0.00");