public void TestPartitionForPrimeNumbersInPlace()
        {
            Func <int, bool> isPrime = (n) =>
            {
                if (n < 2)
                {
                    return(false);
                }
                if (n == 2)
                {
                    return(true);
                }

                int max = (int)Math.Pow(n, 0.5) + 1;
                for (int i = 2; i < max; i++)
                {
                    if (n % i == 0)
                    {
                        return(false);
                    }
                }

                return(true);
            };

            var arr = new int[] { 3, 50, 2, 11, 42, 8, 4 };

            var par = new PartitionItemsInArray();

            par.PartitionPolicyInPlace(arr, isPrime);

            Assert.That(arr.SequenceEqual(new int[] { 3, 2, 11, 50, 42, 8, 4 }), Is.True);
        }
        public void TestPartitionAccordingToAPolicyInPlace()
        {
            var arr = new int[] { 3, 50, 2, 11, 42, 8, 4 };

            Func <int, bool> policy = (n) => n % 2 == 0;

            var par = new PartitionItemsInArray();

            par.PartitionPolicyInPlace(arr, policy);

            Assert.That(arr.SequenceEqual(new int[] { 50, 2, 42, 8, 4, 11, 3 }), Is.True);
        }