private static void Sort_UndoCount_Test(string xml, SortOrder order)
        {
            var x2o = new GranitXmlToAdapterBinder(xml, true);

            Assert.AreEqual(x2o.History.UndoCount, 0);
            x2o.Sort(Constants.ExecutionDatePropertyName, order);
            Assert.AreEqual(x2o.History.UndoCount, 1);
        }
        private static void Amount_Sort_and_MinMax_Test(string xml, SortOrder order)
        {
            var x2o = new GranitXmlToAdapterBinder(xml, true);

            x2o.Sort(Constants.AmountPropertyName, order);
            decimal maxAmount   = x2o.HUFTransactionsAdapter.TransactionAdapters.Max(ta => ta.Amount);
            decimal minAmount   = x2o.HUFTransactionsAdapter.TransactionAdapters.Min(ta => ta.Amount);
            string  firstAmount = x2o.GranitXDocument.Root.Elements(GranitXml.Constants.Transaction).First().Element(GranitXml.Constants.Amount).Value;
            string  lastAmount  = x2o.GranitXDocument.Root.Elements(GranitXml.Constants.Transaction).Last().Element(GranitXml.Constants.Amount).Value;

            string[] amounts  = x2o.GranitXDocument.Root.Elements(GranitXml.Constants.Transaction).Elements(GranitXml.Constants.Amount).Select(t => t.Value).ToArray();
            string   s_before = amounts[0];

            if (order == SortOrder.Descending)
            {
                Assert.AreEqual(decimal.Parse(firstAmount, NumberStyles.Number, CultureInfo.InvariantCulture),
                                maxAmount);
                Assert.AreEqual(decimal.Parse(lastAmount, NumberStyles.Number, CultureInfo.InvariantCulture),
                                minAmount);
                foreach (var s in amounts)
                {
                    Assert.IsTrue(
                        decimal.Parse(s_before, NumberStyles.Number, CultureInfo.InvariantCulture) >=
                        decimal.Parse(s, NumberStyles.Number, CultureInfo.InvariantCulture));
                    s_before = s;
                }
            }
            else
            {
                Assert.AreEqual(decimal.Parse(firstAmount, NumberStyles.Number, CultureInfo.InvariantCulture),
                                minAmount);
                Assert.AreEqual(decimal.Parse(lastAmount, NumberStyles.Number, CultureInfo.InvariantCulture),
                                maxAmount);
                foreach (var s in amounts)
                {
                    Assert.IsTrue(
                        decimal.Parse(s_before, NumberStyles.Number, CultureInfo.InvariantCulture) <=
                        decimal.Parse(s, NumberStyles.Number, CultureInfo.InvariantCulture));
                    s_before = s;
                }
            }
            Assert.AreEqual(x2o.History.UndoCount, 1);
        }
        private static void Sort_ReqDate_Test(string xml, SortOrder order)
        {
            var x2o = new GranitXmlToAdapterBinder(xml, true);

            x2o.Sort(Constants.ExecutionDatePropertyName, order);

            DateTime maxDate   = x2o.HUFTransactionsAdapter.TransactionAdapters.Max(ta => ta.ExecutionDate);
            DateTime minDate   = x2o.HUFTransactionsAdapter.TransactionAdapters.Min(ta => ta.ExecutionDate);
            string   firstDate = x2o.GranitXDocument.Root.Elements(Constants.Transaction).InDocumentOrder().First().Element(Constants.RequestedExecutionDate).Value;
            string   lastDate  = x2o.GranitXDocument.Root.Elements(Constants.Transaction).InDocumentOrder().Last().Element(Constants.RequestedExecutionDate).Value;

            if (order == SortOrder.Descending)
            {
                Assert.AreEqual(DateTime.Parse(firstDate), maxDate);
                Assert.AreEqual(DateTime.Parse(lastDate), minDate);
            }
            else
            {
                Assert.AreEqual(DateTime.Parse(firstDate), minDate);
                Assert.AreEqual(DateTime.Parse(lastDate), maxDate);
            }
        }