Exemple #1
0
        private void PropertyTestImpl(
            string propNameOrValueKey,
            string keyOrTypeName,
            string keyOrValue,
            string stepText,
            bool isValue,
            string propName2      = null,
            string keyOrTypeName2 = null)
        {
            string    compareText = GetCompareText(stepText);
            CompareOp compareOp   = ToCompareOp(compareText);

            //Console.WriteLine($"***** PropertyTest:  propName: <{propNameOrValueKey}>, keyOrTypeName: <{keyOrTypeName}>, keyOrValue: <{keyOrValue}>, compare: <{compareOp}>, propName2: <{propName2}>, keyOrTypeName2: <{keyOrTypeName2}>");

            GetPropertyOrFieldData(propNameOrValueKey, keyOrTypeName, out object instance, out PropertyInfo prop, out FieldInfo field);
            GetPropertyOrFieldData(propName2, keyOrTypeName2, out object instance2, out PropertyInfo prop2, out FieldInfo field2);

            ITypeProcessor actual   = GetProcessorFor(propNameOrValueKey, instance, prop, field);
            ITypeProcessor expected = null;

            if (!IsSingleCompareOp(compareOp))
            {
                if (isValue)
                {
                    expected = actual.Clone();
                    expected.SetValue(keyOrValue);
                }
                else
                {
                    expected = GetProcessorFor(keyOrValue, instance2, prop2, field2);
                }
            }

            if (expected == null)
            {
                expected = new ObjectProcessor(_scenario);
                expected.PostCurrentValue();
            }

            DoCompare(actual, expected, compareOp);
        }
Exemple #2
0
        protected static void DoCompare(ITypeProcessor actual, ITypeProcessor expected, CompareOp compareOp)
        {
            if (actual == null)
            {
                if (expected != null)
                {
                    actual = expected.Clone();
                    actual.ReadFromContext();
                }
            }

            Console.WriteLine($"***** Actual: {(actual != null ? actual.ToString() : "NULL")}");
            Console.WriteLine($"***** Expected: {(expected != null ? expected.ToString() : "NULL")}");

            if (actual == null || (expected == null && !IsSingleCompareOp(compareOp)))
            {
                throw new Exception($"Unable to parse test step.");
            }

            actual.CompareTo(expected, compareOp);
        }