Ejemplo n.º 1
0
        public static List <TestResult> PushPullCompare(IBHoMAdapter adapter, List <IBHoMObject> testObjects, string setName = "", Type enforcedType = null, PushPullCompareConfig config = null, bool active = false)
        {
            if (!active)
            {
                return(new List <TestResult>());
            }

            if (enforcedType != null && testObjects.Any(x => !enforcedType.IsAssignableFrom(x.GetType())))
            {
                Base.Compute.RecordError("The testObjects is not matching the enforced type and are not a subtype of the enforced type.");
                return(new List <TestResult>());
            }

            config = config ?? new PushPullCompareConfig();

            IEqualityComparer <IBHoMObject> comparer = config.Comparer(adapter.AdapterIdFragmentType);

            List <TestResult> testResults = new List <TestResult>();

            if (enforcedType == null)
            {
                foreach (var group in testObjects.GroupBy(x => x.GetType()))
                {
                    FilterRequest request = new FilterRequest {
                        Type = group.Key
                    };

                    testResults.Add(RunOneSet(adapter, setName, group.ToList(), request, comparer, config.ResetModelBetweenPushes));
                }
            }
            else
            {
                FilterRequest request = new FilterRequest {
                    Type = enforcedType
                };
                testResults.Add(RunOneSet(adapter, setName, testObjects, request, comparer, config.ResetModelBetweenPushes));
            }
            return(testResults);
        }
Ejemplo n.º 2
0
        public static List <TestResult> PushPullCompare(IBHoMAdapter adapter, Type type, PushPullCompareConfig config = null, bool active = false)
        {
            if (!active)
            {
                return(new List <TestResult>());
            }

            config = config ?? new PushPullCompareConfig();

            //Get testdata
            var testSets = Query.TestDataOfType(type);

            if (testSets == null || testSets.Item1 == null || testSets.Item2 == null)
            {
                Base.Compute.RecordError("Failed to extract testdata");
                return(new List <TestResult>());
            }

            List <string> testSetNames          = testSets.Item1;
            List <List <IBHoMObject> > testData = testSets.Item2;

            //Set up comparer and request
            FilterRequest request = new FilterRequest {
                Type = type
            };
            IEqualityComparer <IBHoMObject> comparer = config.Comparer(adapter.AdapterIdFragmentType);

            //List for storing output

            List <TestResult> results = new List <TestResult>();


            for (int i = 0; i < testSetNames.Count; i++)
            {
                results.Add(RunOneSet(adapter, testSetNames[i], testData[i], request, comparer, config.ResetModelBetweenPushes));
            }

            return(results);
        }