public void Apply()
        {
            Order order            = Order.Asc("Value");
            OrderExitOperation oeo = new OrderExitOperation(order);
            IList unRandomList     = oeo.Apply(shuffledList);

            for (int i = 0; i < unRandomList.Count; i++)
            {
                Assert.IsTrue(unRandomList[i].Equals(nonNullData[i]));
            }
        }
        public IList Apply(IList result)
        {
            /**
             * Herein lies the glory
             *
             * hibernate has done as much as it can, we're going to have to deal with
             * the rest in memory.
             *
             * The heirarchy of operations is this so far:
             * Distinct
             * Order
             * FirstResult
             * MaxResult
             * RowCount
             * Average
             * Min/Max/Sum
             */

            // ordering of the following operations *really* matters!
            if (distinct != null)
            {
                result = new DistinctExitOperation(distinct).Apply(result);
            }
            foreach (Order order in orders)
            {
                result = new OrderExitOperation(order).Apply(result);
            }
            if (firstResult != null)
            {
                result = new FirstResultExitOperation((int)firstResult).Apply(result);
            }
            if (maxResults != null)
            {
                result = new MaxResultsExitOperation((int)maxResults).Apply(result);
            }
            ProjectionExitOperationFactory factory = ProjectionExitOperationFactory.GetFactory();

            if (rowCountProjection != null)
            {
                result = factory.GetProjectionExitOperation(rowCountProjection, sessionFactoryImplementor).Apply(result);
            }
            if (avgProjection != null)
            {
                result = new AvgResultsExitOperation().Apply(result);
            }
            // min, max, sum
            if (aggregateProjection != null)
            {
                result = factory.GetProjectionExitOperation(aggregateProjection, sessionFactoryImplementor).Apply(result);
            }

            return(result);
        }
        public void MultipleOrderings()
        {
            Order orderValue = Order.Asc("Value");
            Order orderName  = Order.Desc("Name");

            OrderExitOperation oeoValue = new OrderExitOperation(orderValue);
            OrderExitOperation oeoName  = new OrderExitOperation(orderName);

            List <MyInt> answer = new List <MyInt>(new MyInt[]
            {
                new MyInt(0, "tomislav"),
                new MyInt(1, "max"),
                new MyInt(2, "maulik"),
                new MyInt(3, "gut"),
                new MyInt(5, "bomb")
            });

            IList unShuffledList = oeoName.Apply(oeoValue.Apply(shuffledList));

            for (int i = 0; i < answer.Count; i++)
            {
                Assert.AreEqual(answer[i], unShuffledList[i], "The element {0} of the collecion is not equal", i);
            }
        }