Click here to Skip to main content
15,881,882 members
Articles / Programming Languages / C#

ObjectLounge - An Object-Oriented Database Framework

Rate me:
Please Sign up or sign in to vote.
4.07/5 (8 votes)
30 Jul 2009LGPL310 min read 43.6K   425   45  
Host your Domain Models "Out Of The Box" + No storage or schema needed + Transactions on Domain Models + Validation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Technewlogic.Stasy.Test.Model;
using Technewlogic.Stasy.Framework.Proxy;
using Technewlogic.Stasy.Framework;
using System.Threading;
using Technewlogic.Stasy.Framework.Transactions;
using Technewlogic.Stasy.Framework.UnitOfWork;

namespace Technewlogic.Stasy.Test.MetaModelTests
{
	class ContextReadableError
	{
		[EntityCollection]
		public CompositeCollection<Customer> Customers { get; set; }

		[EntityCollection]
		public CompositeCollection<OrderTypeCompositor> OrderTypeCompositors { get; set; }

		[EntityCollection]
		public List<OrderType> OrderTypes { get; set; }

		[EntityCollection]
		public IEnumerable<Order> Orders { get; set; }

		[EntityCollection]
		public IEnumerable<Material> Materials { get; set; }
	}

	class ContextWritableError
	{
		[EntityCollection]
		public CompositeCollection<Customer> Customers { get; set; }

		[EntityCollection]
		public List<OrderTypeCompositor> OrderTypeCompositors { get; set; }

		[EntityCollection]
		public IEnumerable<OrderType> OrderTypes { get; set; }

		[EntityCollection]
		public IEnumerable<Order> Orders { get; set; }

		[EntityCollection]
		public IEnumerable<Material> Materials { get; set; }
	}

	[TestFixture]
	public class General
	{
		[TestFixtureSetUp]
		public void TestFixtureSetUp()
		{
		}

		[SetUp]
		public void SetUp()
		{
		}

		[Test]
		[ExpectedException(typeof(ModelConfigurationException),
			ExpectedMessage = "The collection property 'OrderTypes' registered in the context must be of type 'IEnumerable`1', but it is of type 'List`1'.")]
		public void WrongContextCollectionConfiguration_Readable()
		{
			var context = new ContextReadableError();
			var engine = EngineFactory.CreateEngine(
				new DataContextMockSyncProvider(new DataContextMock()),
				context);
		}

		[Test]
		[ExpectedException(typeof(ModelConfigurationException),
			ExpectedMessage = "The collection property 'OrderTypeCompositors' registered in the context must be of type 'CompositeCollection`1', but it is of type 'List`1'.")]
		public void WrongContextCollectionConfiguration_Writable()
		{
			var context = new ContextWritableError();
			var engine = EngineFactory.CreateEngine(
				new DataContextMockSyncProvider(new DataContextMock()),
				context);
		}
	}
}

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 GNU Lesser General Public License (LGPLv3)


Written By
Software Developer (Senior) www.technewlogic.de
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions