Example #1
0
 public FakeComparisonResult(ElementChangeResult[] changedResult = null, ElementAddRemoveResult[] addedResult = null, 
     ElementAddRemoveResult[] removedResult = null, int unchangedItems = 0, decimal cssPercent = 0, decimal textPercent = 0, 
     decimal overallPercent = 0, PixelResult pixelResult = null, HtmlResult htmlResult = null, string htmlDiff = null)
 {
     _changedResult  = changedResult;
     _addedResult    = addedResult;
     _removedResult  = removedResult;
     _unchangedItems = unchangedItems;
     _cssPercent     = cssPercent;
     _textPercent    = textPercent;
     _overallPercent = overallPercent;
     _pixelResult    = pixelResult;
     _htmlResult     = htmlResult;
     _htmlDiff       = htmlDiff;
 }
Example #2
0
        // TODO: high value testing area
        private bool HasChanges(ScrapedElement element, Image pageScreenshotA, Image pageScreenshotB, Scrape pageA, Scrape pageB, out ElementChangeResult changes)
        {
            var correspondingScrapedElement = element.CorrespondingScrapedElement;
            changes = new ElementChangeResult();

            var changed = false;

            // Location changed
            decimal percentageChange = 0;
            if (!correspondingScrapedElement.Location.Equals(element.Location))
            {
                changed = true;
                changes.LocationChanges = GetLocationChanges(correspondingScrapedElement.Location, element.Location, out percentageChange);
            }

            changes.LocationPercentageChange = percentageChange;

            // Css changed
            percentageChange = 0;
            if (!correspondingScrapedElement.Css.DictionaryEqual(element.Css))
            {
                changed = true;
                changes.CssChanges = GetCssChanges(correspondingScrapedElement.Css, element.Css, out percentageChange);
            }

            changes.CssPercentageChange = percentageChange;

            // Html changed
            percentageChange = 0;
            if (correspondingScrapedElement.Html != element.Html)
            {
                changed = true;
                changes.HtmlChanges = GetStringChanges(correspondingScrapedElement.Html, element.Html, out percentageChange);
            }

            changes.HtmlPercentageChange = percentageChange;

            // Text changed
            percentageChange = 0;
            if (correspondingScrapedElement.Text != element.Text)
            {
                changed = true;
                changes.TextChanges = GetStringChanges(correspondingScrapedElement.Text, element.Text, out percentageChange);
            }

            changes.TextPercentageChange = percentageChange;

            // Pixels changed
            changes.PixelChanges = GetPixelChanges(pageScreenshotA, pageScreenshotB, element, correspondingScrapedElement, pageA, pageB, out percentageChange);
            changes.PixelPercentageChange = percentageChange;
            if (percentageChange > 0M)
            {
                changed = true;
            }

            // Store location on screenshot
            changes.LocationOnScreenshot = element.LocationOnScreenshot;

            return changed;
        }
Example #3
0
        public ElementChangeResult[] TooMany()
        {
            var ch = new ElementChangeResult[51];
            for (int i = 0; i < 51; i++)
            {
                ch[i] = new ElementChangeResult
                {

                    PixelChanges = new PixelChange
                    {
                        From             = new Bitmap(_dummyImage),
                        FromStyle        = "",
                        FromClipped      = new Bitmap(_dummyImage),
                        FromClippedStyle = "",
                        FromMask         = new Bitmap(_dummyImage),
                        FromMaskStyle    = "",
                        To               = new Bitmap(_dummyImage),
                        ToStyle          = "",
                        ToClipped        = new Bitmap(_dummyImage),
                        ToClippedStyle   = "",
                        ToMask           = new Bitmap(_dummyImage),
                        ToMaskStyle      = "",
                        Diff             = new Bitmap(_dummyImage),
                        DiffStyle        = ""
                    }
                };
            }
            return ch;
        }