Ejemplo n.º 1
0
        private void UserGeneralInfo_Organization_MergingNewTreeToOldOne_Test(OrganizationTreeDescriptor oldTreeRoot, OrganizationTreeDescriptor newTreeRoot)
        {
            var watch = new Stopwatch();

            watch.Start();
            var resultReport = new ResultReport(this.UserId, this.OldId, EnumTestUnitNames.UserGeneralInfo_Organizations_TreeMerged, "Trying to merge Organization Trees together");

            if (newTreeRoot != null && oldTreeRoot != null)
            {
                var newTreeRootDeepClone = newTreeRoot.DeepClone();

                PopulateGapsOfOldTree(this.oldServiceOrganizationDescriptors, this.newServiceOrganizationDescriptors, resultReport, true);

                var missingElements = this.oldServiceOrganizationDescriptors.Where(x => x.HasBeenMatched == false &&
                                                                                   string.IsNullOrEmpty(x.ID) &&
                                                                                   string.IsNullOrEmpty(x.Name) &&
                                                                                   x.Depth >= 0)
                                      .GroupBy(x => x.Depth)
                                      .ToDictionary(t => t.Key, t => t.ToList());
                int countMissingElements = missingElements.Count();

                if (countMissingElements == 0)
                {
                    resultReport.UpdateSeverity(EnumResultSeverityType.SUCCESS);
                }
                else
                {
                    //if (countMissingElements > 0)
                    //{
                    //    PopulateGapsOfOldTree(this.oldServiceOrganizationDescriptors, this.newServiceOrganizationDescriptors, resultReport, false);

                    //    missingElements = this.oldServiceOrganizationDescriptors.Where(x => x.HasBeenMatched == false
                    //                                                    && string.IsNullOrEmpty(x.ID)
                    //                                                    && string.IsNullOrEmpty(x.Name)
                    //                                                    && x.Depth >= 0)
                    //                                       .GroupBy(x => x.Depth)
                    //                                       .ToDictionary(t => t.Key, t => t.ToList());
                    //    countMissingElements = missingElements.Count();
                    //}

                    if (countMissingElements == 0)
                    {
                        resultReport.UpdateSeverity(EnumResultSeverityType.FALSE_POSITIVE);
                    }
                    else
                    {
                        resultReport.UpdateSeverity(EnumResultSeverityType.ERROR);
                    }
                }

                OrganizationTreeDescriptor root = null;

                try
                {
                    root = this.oldServiceOrganizationDescriptors.Where(x => x.Depth == 0).First();
                } catch (Exception)
                { }

                resultReport.AddDetailedValues(null, root, null, newTreeRootDeepClone);
            }
            else
            {
                resultReport.UpdateSeverity(EnumResultSeverityType.WARNING_NO_DATA);
            }


            watch.Stop();
            resultReport.Duration = watch.Elapsed;
            this.DetailedResults.Add(resultReport.TestName, resultReport);

            LogManager.Instance.LogTestResult(this.Container.BuildOldServiceFullURL(this.OldId),
                                              this.BuildNewServiceURL(this.PageName),
                                              resultReport);
        }
Ejemplo n.º 2
0
        private void UserGeneralInfo_Organization_CheckTreeDepthCoherence_Test(OrganizationTreeDescriptor oldTreeRoot, OrganizationTreeDescriptor newTreeRoot)
        {
            bool keepGoing = true;
            int  index     = 0;
            IEnumerable <OrganizationTreeDescriptor> oldEntriesSameDepth;
            IEnumerable <OrganizationTreeDescriptor> newEntriesSameDepth;
            int oldCount;
            int newCount;

            var watch = new Stopwatch();

            watch.Start();
            var resultReport = new ResultReport(this.UserId, this.OldId, EnumTestUnitNames.UserGeneralInfo_Organizations_TreeDepthCoherence, "Comparing Organization Tree Depth Coherence");

            while (keepGoing)
            {
                oldEntriesSameDepth = this.oldServiceOrganizationDescriptors.Where(x => x.Depth == index);
                newEntriesSameDepth = this.newServiceOrganizationDescriptors.Where(s => s.Depth == index);

                oldCount = oldEntriesSameDepth.Count();
                newCount = newEntriesSameDepth.Count();

                if (oldCount == 0 && newCount == 0)
                {
                    keepGoing = false;
                }

                try
                {
                    // the only we can compare is that the old tree does not return more entries than the new one at a given depth of depth
                    // the new service may return more because it has enriched the old tree where some of the values may have been manually - ? - excluded
                    Assert.IsFalse(oldCount > newCount, "Comparing at depth index " + index);

                    resultReport.UpdateSeverity(EnumResultSeverityType.SUCCESS);
                }
                catch (AssertFailedException e)
                {
                    resultReport.UpdateSeverity(EnumResultSeverityType.ERROR);
                    resultReport.ErrorMessage = e.Message;
                    resultReport.IdentifedDataBehaviors.Add(EnumIdentifiedDataBehavior.OLD_TREE_HAS_MORE_CHILDREN_GIVEN_DEPTH);
                    resultReport.AddDetailedValues(this.oldServiceOrganizationDescriptors, oldTreeRoot, this.newServiceOrganizationDescriptors, newTreeRoot);
                    resultReport.TreeComparisonIndexError = index;

                    if (resultReport.Severity == EnumResultSeverityType.ERROR)
                    {
                        keepGoing = false;
                    }
                }

                index++;
            }

            if (resultReport.Severity == EnumResultSeverityType.SUCCESS)
            {
                resultReport.IdentifedDataBehaviors.Add(EnumIdentifiedDataBehavior.NEW_TREE_COUNT_CONSISTENT);
                resultReport.AddDetailedValues(this.oldServiceOrganizationDescriptors, oldTreeRoot, this.newServiceOrganizationDescriptors, newTreeRoot);
            }

            watch.Stop();
            resultReport.Duration = watch.Elapsed;

            this.DetailedResults.Add(resultReport.TestName, resultReport);

            LogManager.Instance.LogTestResult(this.Container.BuildOldServiceFullURL(this.OldId),
                                              this.BuildNewServiceURL(this.PageName),
                                              resultReport);
        }