Exemplo n.º 1
0
        private static bool AreEqual(OrderItem[] expected, OrderItem[] actual)
        {
            if ((expected == null) != (actual == null)) return false;
            if (expected != null)
            {
                if (expected.Length != actual.Length) return false;
                for (var i = 0; i < expected.Length; i++)
                {
                    if (!expected[i].Equals(actual[i])) return false;
                }
            }

            return true;
        }
Exemplo n.º 2
0
        private static bool Compare(OrderItem expected, OrderItem actual, List<string> differences)
        {
            if ((expected == null) != (actual == null))
            {
                differences.Add("One order item is null, other is not");
                return false;
            }

            if (expected != null)
            {
                if (expected.Name != actual.Name)
                {
                    differences.Add("Expected item name (" + expected.Name + ") != actual (" + actual.Name + ")");
                    return false;
                }

                if (expected.Quantity != actual.Quantity)
                {
                    differences.Add("Expected item quantity (" + expected.Quantity + ") != actual (" + actual.Quantity + ")");
                    return false;
                }

                const double AcceptableDifference = 0.000001;
                if (Math.Abs(expected.Price - actual.Price) > AcceptableDifference)
                {
                    differences.Add("Expected item price (" + expected.Price + ") != actual (" + actual.Price + ")");
                    return false;
                }
            }

            return true;
        }