All pastes #901648 Raw Edit

Mine

public text v1 · immutable
·published 2008-02-12 21:01 UTC
rendered paste body
/* Copyright (C) 2007 - 2008  db4objects Inc.  http://www.db4o.com */

using System;
using System.Collections.Generic;
using System.Linq;

using Db4objects.Db4o;
using Db4objects.Db4o.Linq;

using Db4oUnit;
using Db4oUnit.Extensions;

namespace Db4objects.Db4o.Linq.Tests
{
	public class EnumIssueTestCase : AbstractDb4oTestCase
	{
		public enum Kind
		{
			Other = 0,
			Plane = 1,
			Car = 2,
		}

		public class Thing
		{
			public Kind Kind;

			public override bool Equals(object obj)
			{
				Thing t = obj as Thing;
				if (t == null) return false;

				return t.Kind == this.Kind;
			}

			public override int GetHashCode()
			{
				return this.Kind.GetHashCode();
			}
		}

		protected override void Store()
		{
			Store(new Thing { Kind = Kind.Plane });
			Store(new Thing { Kind = Kind.Car });
			Store(new Thing { Kind = Kind.Plane });
			Store(new Thing { Kind = Kind.Other });
		}

		public void TestEqualsConstant()
		{
			var q = NewQuery();
			q.Constrain(typeof(Thing));
			q.Descend("Kind").Constrain(1);

			var set = q.Execute();

			Assert.AreEqual(2, set.Count);
		}
	}
}