コード例 #1
0
 public void PixelType_PropertyValueIsCorrect <TPixel>(TestImageProvider <TPixel> provider, PixelTypes expected)
     where TPixel : struct, IPixel <TPixel>
 {
     Assert.Equal(expected, provider.PixelType);
 }
コード例 #2
0
        public void GetImage_WithCustomParametricDecoder_ShouldNotUtilizeCache_WhenParametersAreNotEqual <TPixel>(TestImageProvider <TPixel> provider)
            where TPixel : struct, IPixel <TPixel>
        {
            Assert.NotNull(provider.Utility.SourceFileOrDescription);

            TestDecoderWithParameters.DoTestThreadSafe(() =>
            {
                string testName =
                    nameof(this.GetImage_WithCustomParametricDecoder_ShouldNotUtilizeCache_WhenParametersAreNotEqual);

                var decoder1 = new TestDecoderWithParameters()
                {
                    Param1 = "Lol", Param2 = 42
                };
                decoder1.InitCaller(testName);

                var decoder2 = new TestDecoderWithParameters()
                {
                    Param1 = "LoL", Param2 = 42
                };
                decoder2.InitCaller(testName);

                provider.GetImage(decoder1);
                Assert.Equal(1, TestDecoderWithParameters.GetInvocationCount(testName));

                provider.GetImage(decoder2);
                Assert.Equal(2, TestDecoderWithParameters.GetInvocationCount(testName));
            });
        }
コード例 #3
0
 public void NoOutputSubfolderIsPresentByDefault <TPixel>(TestImageProvider <TPixel> provider)
     where TPixel : struct, IPixel <TPixel>
 {
     Assert.Empty(provider.Utility.OutputSubfolderName);
 }
コード例 #4
0
 public void WorksWithAllCompressionLevels <TPixel>(TestImageProvider <TPixel> provider, int compressionLevel)
     where TPixel : struct, IPixel <TPixel>
 {
     TestPngEncoderCore(provider, PngColorType.RgbWithAlpha, PngFilterMethod.Adaptive, compressionLevel, appendCompressionLevel: true);
 }
コード例 #5
0
        public void GetImage_WithCustomParametricDecoder_ShouldUtilizeCache_WhenParametersAreEqual <TPixel>(TestImageProvider <TPixel> provider)
            where TPixel : struct, IPixel <TPixel>
        {
            if (!TestEnvironment.Is64BitProcess)
            {
                // We don't cache with the 32 bit build.
                return;
            }

            Assert.NotNull(provider.Utility.SourceFileOrDescription);

            TestDecoderWithParameters.DoTestThreadSafe(() =>
            {
                string testName =
                    nameof(this.GetImage_WithCustomParametricDecoder_ShouldUtilizeCache_WhenParametersAreEqual);

                var decoder1 = new TestDecoderWithParameters()
                {
                    Param1 = "Lol", Param2 = 666
                };
                decoder1.InitCaller(testName);

                var decoder2 = new TestDecoderWithParameters()
                {
                    Param1 = "Lol", Param2 = 666
                };
                decoder2.InitCaller(testName);

                provider.GetImage(decoder1);
                Assert.Equal(1, TestDecoderWithParameters.GetInvocationCount(testName));

                provider.GetImage(decoder2);
                Assert.Equal(1, TestDecoderWithParameters.GetInvocationCount(testName));
            });
        }
コード例 #6
0
 public void IsNotBoundToSinglePixelType <TPixel>(TestImageProvider <TPixel> provider, PngColorType pngColorType)
     where TPixel : struct, IPixel <TPixel>
 {
     TestPngEncoderCore(provider, pngColorType, PngFilterMethod.Adaptive, appendPixelType: true, appendPngColorType: true);
 }
コード例 #7
0
 public void WorksWithAllFilterMethods <TPixel>(TestImageProvider <TPixel> provider, PngFilterMethod pngFilterMethod)
     where TPixel : struct, IPixel <TPixel>
 {
     TestPngEncoderCore(provider, PngColorType.RgbWithAlpha, pngFilterMethod, appendPngFilterMethod: true);
 }
コード例 #8
0
 public void PaletteColorType_WuQuantizer <TPixel>(TestImageProvider <TPixel> provider, int paletteSize)
     where TPixel : struct, IPixel <TPixel>
 {
     TestPngEncoderCore(provider, PngColorType.Palette, PngFilterMethod.Adaptive, paletteSize: paletteSize, appendPaletteSize: true);
 }
コード例 #9
0
 public void WorksWithDifferentSizes <TPixel>(TestImageProvider <TPixel> provider, PngColorType pngColorType)
     where TPixel : struct, IPixel <TPixel>
 {
     TestPngEncoderCore(provider, pngColorType, PngFilterMethod.Adaptive, appendPngColorType: true);
 }
コード例 #10
0
        public void TolerantImageComparer_DoesNotApproveSimilarityAboveTolerance <TPixel>(TestImageProvider <TPixel> provider)
            where TPixel : struct, IPixel <TPixel>
        {
            using (Image <TPixel> image = provider.GetImage())
            {
                using (Image <TPixel> clone = image.Clone())
                {
                    byte perChannelChange = 2;
                    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);
                }
            }
        }
コード例 #11
0
 public void CreateAndResize(TestImageProvider <Rgba32> provider)
 {
     using Image <Rgba32> image = provider.GetImage();
     image.Mutate(c => c.Resize(1000, 1000));
     image.DebugSave(provider);
 }
コード例 #12
0
 public void OutputSubfolderName_ValueIsTakeFromGroupOutputAttribute <TPixel>(TestImageProvider <TPixel> provider)
     where TPixel : struct, IPixel <TPixel>
 {
     Assert.Equal("Foo", provider.Utility.OutputSubfolderName);
 }
コード例 #13
0
        public void GetImage_WithCustomParameterlessDecoder_ShouldUtilizeCache <TPixel>(TestImageProvider <TPixel> provider)
            where TPixel : struct, IPixel <TPixel>
        {
            Assert.NotNull(provider.Utility.SourceFileOrDescription);

            TestDecoder.DoTestThreadSafe(
                () =>
            {
                string testName = nameof(this.GetImage_WithCustomParameterlessDecoder_ShouldUtilizeCache);

                var decoder = new TestDecoder();
                decoder.InitCaller(testName);

                provider.GetImage(decoder);
                Assert.Equal(1, TestDecoder.GetInvocationCount(testName));

                provider.GetImage(decoder);
                Assert.Equal(1, TestDecoder.GetInvocationCount(testName));
            });
        }
コード例 #14
0
ファイル: BmpEncoderTests.cs プロジェクト: sagron/ImageSharp
 public void Encode_WorksWithDifferentSizes <TPixel>(TestImageProvider <TPixel> provider, BmpBitsPerPixel bitsPerPixel)
     where TPixel : struct, IPixel <TPixel>
 {
     TestBmpEncoderCore(provider, bitsPerPixel);
 }
コード例 #15
0
ファイル: BmpEncoderTests.cs プロジェクト: sagron/ImageSharp
 public void Encode_IsNotBoundToSinglePixelType <TPixel>(TestImageProvider <TPixel> provider, BmpBitsPerPixel bitsPerPixel)
     where TPixel : struct, IPixel <TPixel>
 {
     TestBmpEncoderCore(provider, bitsPerPixel);
 }
コード例 #16
0
 public void CompareToReferenceOutput_WhenReferenceFileMissing_Throws <TPixel>(TestImageProvider <TPixel> provider)
     where TPixel : unmanaged, IPixel <TPixel>
 {
     using (Image <TPixel> image = provider.GetImage())
     {
         Assert.ThrowsAny <Exception>(() => image.CompareToReferenceOutput(provider));
     }
 }