Exemple #1
0
        public void Reset_AllSettingsChanged_RestoredToDefault()
        {
            var script = new TextCleanerScript();

            script.AdaptiveBlur       = 2;
            script.BackgroundColor    = new MagickColor("yellow");
            script.CropOffset.Left    = 1;
            script.CropOffset.Top     = 1;
            script.CropOffset.Right   = 1;
            script.CropOffset.Bottom  = 1;
            script.Enhance            = TextCleanerEnhance.Normalize;
            script.FilterOffset       = (Percentage)10;
            script.FilterSize         = 10;
            script.Layout             = TextCleanerLayout.Landscape;
            script.MakeGray           = true;
            script.Padding            = 15;
            script.Rotation           = TextCleanerRotation.Clockwise;
            script.Saturation         = (Percentage)150;
            script.Sharpen            = 1;
            script.SmoothingThreshold = (Percentage)50;
            script.Trim     = true;
            script.Unrotate = true;

            script.Reset();

            AssertDefaults(script);
        }
        public void Test_Settings()
        {
            var script = new TextCleanerScript();

            using (var logo = new MagickImage(Images.Logo))
            {
                script.Execute(logo);

                ExceptionAssert.Throws <InvalidOperationException>(() =>
                {
                    script.AdaptiveBlur = -1;
                    script.Execute(logo);
                });

                ExceptionAssert.Throws <InvalidOperationException>(() =>
                {
                    script.Reset();
                    script.CropOffset.Bottom = -1;
                    script.Execute(logo);
                });

                ExceptionAssert.Throws <InvalidOperationException>(() =>
                {
                    script.Reset();
                    script.CropOffset.Left = -1;
                    script.Execute(logo);
                });

                ExceptionAssert.Throws <InvalidOperationException>(() =>
                {
                    script.Reset();
                    script.CropOffset.Right = -1;
                    script.Execute(logo);
                });

                ExceptionAssert.Throws <InvalidOperationException>(() =>
                {
                    script.Reset();
                    script.CropOffset.Top = -1;
                    script.Execute(logo);
                });

                ExceptionAssert.Throws <InvalidOperationException>(() =>
                {
                    script.Reset();
                    script.FilterSize = -1;
                    script.Execute(logo);
                });

                ExceptionAssert.Throws <InvalidOperationException>(() =>
                {
                    script.Reset();
                    script.Padding = -1;
                    script.Execute(logo);
                });

                ExceptionAssert.Throws <InvalidOperationException>(() =>
                {
                    script.Reset();
                    script.Sharpen = -1;
                    script.Execute(logo);
                });

                ExceptionAssert.Throws <InvalidOperationException>(() =>
                {
                    script.Reset();
                    script.Saturation = (Percentage)(-1);
                    script.Execute(logo);
                });

                ExceptionAssert.Throws <InvalidOperationException>(() =>
                {
                    script.Reset();
                    script.SmoothingThreshold = (Percentage)150;
                    script.Execute(logo);
                });

                ExceptionAssert.Throws <InvalidOperationException>(() =>
                {
                    script.Reset();
                    script.SmoothingThreshold = (Percentage)(-50);
                    script.Execute(logo);
                });
            }
        }