Beispiel #1
0
        /***************************************************/

        private static oM.Test.ITestInformation GetSameIDInformation(this IEnumerable <oM.Test.ITestInformation> infoList, PushPullObjectComparison toFind)
        {
            //Find exact match
            oM.Test.ITestInformation found = infoList.FirstOrDefault(x => x.IHasMatchingIDs(toFind));

            //If no exact match found, look for partial match
            if (found == null)
            {
                found = infoList.OfType <PushPullObjectComparison>().FirstOrDefault(x => x.PropertyID.Contains(toFind.PropertyID) || toFind.PropertyID.Contains(x.PropertyID));
            }
            return(found);
        }
Beispiel #2
0
        public static oM.Test.ITestInformation ICompare(oM.Test.ITestInformation result, oM.Test.ITestInformation refResult)
        {
            if (result == null)
            {
                return(null);
            }

            if (refResult == null)
            {
                return(result.INoReferenceFound());
            }

            return(Compare(result as dynamic, refResult as dynamic));
        }
Beispiel #3
0
        public static TestResult Compare(TestResult result, TestResult refResult)
        {
            if (result == null)
            {
                return(null);
            }

            if (refResult == null)
            {
                return(result.NoReferenceFound());
            }

            TestResult diffResult = new TestResult()
            {
                Description = $"PushPullCompare difference: {result.ID}", ID = result.ID
            };

            //Check if same type, i.e. Pass/Warning/Error
            if (result.Status == refResult.Status)
            {
                if (result.Status == oM.Test.TestStatus.Warning)
                {
                    //If of type Warning, check the inner results
                    List <oM.Test.ITestInformation> referenceInformation        = refResult.NonEventMessageInformation();
                    List <oM.Test.ITestInformation> referenceInformationNoMatch = referenceInformation.ToList();

                    foreach (oM.Test.ITestInformation innerInformation in result.NonEventMessageInformation())
                    {
                        //Find matching reference data
                        oM.Test.ITestInformation reference = referenceInformation.IGetSameIDInformation(innerInformation);

                        //Compare the inner test information
                        oM.Test.ITestInformation comparisonResult = ICompare(innerInformation, reference);
                        if (comparisonResult != null)
                        {
                            diffResult.Information.Add(comparisonResult);
                        }

                        if (reference != null)
                        {
                            referenceInformationNoMatch.Remove(reference);
                        }
                    }

                    foreach (oM.Test.ITestInformation refInfo in referenceInformationNoMatch)
                    {
                        diffResult.Information.Add(refInfo.IOnlyReferenceFound());
                    }
                }
                else
                {
                    //Else, the results are the same
                    diffResult.Message = "No change in the result status. Was and still is: " + result.Status + ". No changes in differences found from reference data.";
                    diffResult.Status  = oM.Test.TestStatus.Pass;
                    return(diffResult);
                }
            }
            else
            {
                //Result Status are different
                if (refResult.Status == oM.Test.TestStatus.Pass)
                {
                    //Reference is pass, current is not
                    if (result.Status == oM.Test.TestStatus.Error)
                    {
                        //System is now crashing, was working before
                        diffResult.Message = "An error has been introduced that did not exist previously.";
                        diffResult.Status  = oM.Test.TestStatus.Error;
                        return(diffResult);
                    }
                    else if (result.Status == oM.Test.TestStatus.Warning)
                    {
                        //New differences previously not present have been introduced
                        foreach (oM.Test.ITestInformation info in result.NonEventMessageInformation())
                        {
                            diffResult.Information.Add(info.INoReferenceFound());
                        }
                        diffResult.Message  = "Warnings have been introduced with these changes.";
                        diffResult.Message += Environment.NewLine + diffResult.ExceptionProperties(true, true, oM.Test.TestStatus.Warning);
                        diffResult.Status   = oM.Test.TestStatus.Error;
                        return(diffResult);
                    }
                }
                else if (refResult.Status == oM.Test.TestStatus.Error)
                {
                    //Reference is Error, current is not
                    if (result.Status == oM.Test.TestStatus.Pass)
                    {
                        //Was previously crashing, is now returning Pass
                        diffResult.Message = "This test was failing and is now passing under test conditions with the latest changes.";
                        diffResult.Status  = oM.Test.TestStatus.Pass;
                        return(diffResult);
                    }
                    else if (result.Status == oM.Test.TestStatus.Warning)
                    {
                        //Differences are now being flagged up that were not flagged before. Reason being the reference run contained crashes.
                        //Differences still to be logged to be investigated, but this should generally be seen as an improvement
                        //New differences previously not present have been introduced
                        foreach (oM.Test.ITestInformation info in result.NonEventMessageInformation())
                        {
                            diffResult.Information.Add(info.INewResultAfterCrashFix());
                        }
                        diffResult.Message  = "A crash has been fixed. New data shows differences that need to be validated.";
                        diffResult.Message += Environment.NewLine + diffResult.ExceptionProperties(true, true, oM.Test.TestStatus.Warning);
                        diffResult.Status   = oM.Test.TestStatus.Warning;
                        return(diffResult);
                    }
                }
                else if (refResult.Status == oM.Test.TestStatus.Warning)
                {
                    if (result.Status == oM.Test.TestStatus.Pass)
                    {
                        diffResult.Message = "This test previously had warnings which have now been resolved in the latest test.";
                        diffResult.Status  = oM.Test.TestStatus.Pass;

                        //Differences have now been cleared out. Registered as improvement
                        foreach (oM.Test.ITestInformation refInfo in refResult.NonEventMessageInformation())
                        {
                            diffResult.Information.Add(refInfo.IOnlyReferenceFound());
                        }
                    }
                    else if (result.Status == oM.Test.TestStatus.Error)
                    {
                        //System is now crashing, was working before
                        diffResult.Message = "An error has been introduced where previously there were only warnings.";
                        diffResult.Status  = oM.Test.TestStatus.Error;
                        return(diffResult);
                    }
                }
            }

            diffResult.Status = diffResult.Information.MostSevereStatus();

            if (diffResult.Status == oM.Test.TestStatus.Error)
            {
                diffResult.Message = "Differences have been introduced, made worse or have changed.";
            }
            else if (diffResult.Status == oM.Test.TestStatus.Pass)
            {
                diffResult.Message = "No new differences have been introduced.";
            }
            else
            {
                diffResult.Message = "Some differences have either been removed or probably improved. The change is probably for the better but needs to be validated.";
            }

            diffResult.Message += Environment.NewLine + diffResult.ExceptionProperties(true, true, oM.Test.TestStatus.Warning);

            return(diffResult);
        }
Beispiel #4
0
        /***************************************************/

        private static oM.Test.ITestInformation GetSameIDInformation(this IEnumerable <oM.Test.ITestInformation> infoList, oM.Test.ITestInformation toFind)
        {
            return(infoList.FirstOrDefault(x => x.IHasMatchingIDs(toFind)));
        }
Beispiel #5
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private static oM.Test.ITestInformation IGetSameIDInformation(this IEnumerable <oM.Test.ITestInformation> infoList, oM.Test.ITestInformation toFind)
        {
            return(GetSameIDInformation(infoList as dynamic, toFind as dynamic));
        }
Beispiel #6
0
        /***************************************************/
        /**** Private Methods - Fallback                ****/
        /***************************************************/

        private static oM.Test.ITestInformation Compare(oM.Test.ITestInformation result, oM.Test.ITestInformation refResult)
        {
            return(null);
        }