public void CompareToOriginal_WhenDifferent_Throws <TPixel>(TestImageProvider <TPixel> provider)
            where TPixel : struct, IPixel <TPixel>
        {
            using (Image <TPixel> image = provider.GetImage())
            {
                ImagingTestCaseUtility.ModifyPixel(image, 3, 1, 1);

                Assert.ThrowsAny <ImageDifferenceIsOverThresholdException>(() =>
                {
                    image.CompareToOriginal(provider, ImageComparer.Exact);
                });
            }
        }
Exemplo n.º 2
0
        public void TolerantImageComparer_ApprovesSimilarityBelowTolerance <TPixel>(TestImageProvider <TPixel> provider)
            where TPixel : struct, IPixel <TPixel>
        {
            using (Image <TPixel> image = provider.GetImage())
            {
                using (Image <TPixel> clone = image.Clone())
                {
                    ImagingTestCaseUtility.ModifyPixel(clone, 0, 0, 1);

                    var comparer = ImageComparer.Tolerant();
                    comparer.VerifySimilarity(image, clone);
                }
            }
        }
Exemplo n.º 3
0
        public void TolerantImageComparer_TestPerPixelThreshold <TPixel>(TestImageProvider <TPixel> provider)
            where TPixel : struct, IPixel <TPixel>
        {
            using (Image <TPixel> image = provider.GetImage())
            {
                using (Image <TPixel> clone = image.Clone())
                {
                    ImagingTestCaseUtility.ModifyPixel(clone, 0, 0, 10);
                    ImagingTestCaseUtility.ModifyPixel(clone, 1, 0, 10);
                    ImagingTestCaseUtility.ModifyPixel(clone, 2, 0, 10);

                    var comparer = ImageComparer.Tolerant(perPixelManhattanThreshold: 42);
                    comparer.VerifySimilarity(image, clone);
                }
            }
        }
Exemplo n.º 4
0
        public void VerifySimilarity_WhenAnImageFrameIsDifferent_Reports <TPixel>(TestImageProvider <TPixel> provider)
            where TPixel : struct, IPixel <TPixel>
        {
            using (Image <TPixel> image = provider.GetImage())
            {
                using (Image <TPixel> clone = image.Clone())
                {
                    ImagingTestCaseUtility.ModifyPixel(clone.Frames[0], 42, 43, 1);

                    IEnumerable <ImageSimilarityReport> reports = ImageComparer.Exact.CompareImages(image, clone);

                    PixelDifference difference = reports.Single().Differences.Single();
                    Assert.Equal(new Point(42, 43), difference.Position);
                }
            }
        }
Exemplo n.º 5
0
        public void ExactComparer_DoesNotTolerateAnyPixelDifference <TPixel>(TestImageProvider <TPixel> provider)
            where TPixel : struct, IPixel <TPixel>
        {
            using (Image <TPixel> image = provider.GetImage())
            {
                using (Image <TPixel> clone = image.Clone())
                {
                    ImagingTestCaseUtility.ModifyPixel(clone, 42, 24, 1);
                    ImagingTestCaseUtility.ModifyPixel(clone, 7, 93, 1);

                    IEnumerable <ImageSimilarityReport> reports = ExactImageComparer.Instance.CompareImages(image, clone);

                    this.Output.WriteLine(reports.Single().ToString());
                    PixelDifference[] differences = reports.Single().Differences;
                    Assert.Equal(2, differences.Length);
                    Assert.Contains(differences, d => d.Position == new Point(42, 24));
                    Assert.Contains(differences, d => d.Position == new Point(7, 93));
                }
            }
        }
Exemplo n.º 6
0
        public void TolerantImageComparer_DoesNotApproveSimilarityAboveTolerance <TPixel>(TestImageProvider <TPixel> provider)
            where TPixel : unmanaged, IPixel <TPixel>
        {
            using (Image <TPixel> image = provider.GetImage())
            {
                using (Image <TPixel> clone = image.Clone())
                {
                    byte perChannelChange = 20;
                    ImagingTestCaseUtility.ModifyPixel(clone, 3, 1, perChannelChange);

                    var comparer = ImageComparer.Tolerant();

                    ImageDifferenceIsOverThresholdException ex = Assert.ThrowsAny <ImageDifferenceIsOverThresholdException>(
                        () => comparer.VerifySimilarity(image, clone));

                    PixelDifference diff = ex.Reports.Single().Differences.Single();
                    Assert.Equal(new Point(3, 1), diff.Position);
                }
            }
        }