예제 #1
0
        public void RaisePostBackEvent_IfEventArgsAreErrorProne_RegistersStartupScript()
        {
            // Arrange
            var toolImageSize = new ToolImageSize();

            _imageEditor.Toolbar.Tools.Add(toolImageSize);
            _imageEditor.DirectWrite = true;

            var registeredStartupScriptKey   = string.Empty;
            var registeredStartupScriptValue = string.Empty;

            _shimPage.RegisterStartupScriptStringString =
                (key, value) =>
            {
                registeredStartupScriptKey   = key;
                registeredStartupScriptValue = value;
                _registeredScripts[key]      = value;
            };

            // RaisePostBackEvent method eventArgument parameter scheme
            // int width; int height; bool constrainProportions; bool resizeSmaller
            // NOTE: job.ResizeImage() method that called inside of RaisePostBackEvent only resized image if
            // new values are smaller than original. resizeSmaller parameter doesn't work!

            // throw exception
            var raisePostBackEventArgs = "error prone argument to throw exception";

            // Act
            toolImageSize.RaisePostBackEvent(raisePostBackEventArgs);

            // Assert
            _registeredScripts[registeredStartupScriptKey].ShouldBe(registeredStartupScriptValue);
        }
예제 #2
0
        public void RaisePostBackEvent_IfEventArgsAreProper_ResizesAndSavesImage()
        {
            // Arrange
            var toolImageSize = new ToolImageSize();

            _imageEditor.Toolbar.Tools.Add(toolImageSize);
            _imageEditor.DirectWrite = true;

            // RaisePostBackEvent method eventArgument parameter scheme
            // int width; int height; bool constrainProportions; bool resizeSmaller
            // NOTE: job.ResizeImage() method that called inside of RaisePostBackEvent only resized image if
            // new values are smaller than original. resizeSmaller parameter doesn't work!

            // resize
            // width: 100, height: 50
            var raisePostBackEventArgs = "100;50;false;false";

            // Act
            toolImageSize.RaisePostBackEvent(raisePostBackEventArgs);

            // Assert
            var imagePath = _shimHttpServerUtility.Instance.MapPath(_imageEditor.ImageURL);

            using (var image = ActivePixToolsTestHelper.LoadImage(imagePath))
            {
                image.Width.ShouldBe(100);
                image.Height.ShouldBe(50);
            }
        }
예제 #3
0
        public void RaisePostBackEvent_IfDirectWriteSetAsTrue_SavesImageDirectly()
        {
            // Arrange
            var toolImageSize = new ToolImageSize();

            _imageEditor.Toolbar.Tools.Add(toolImageSize);
            _imageEditor.DirectWrite = true;

            // RaisePostBackEvent method eventArgument parameter scheme
            // int width; int height; bool constrainProportions; bool resizeSmaller
            // NOTE: job.ResizeImage() method that called inside of RaisePostBackEvent only resized image if
            // new values are smaller than original. resizeSmaller parameter doesn't work!

            // Args for no changes on image
            var raisePostBackEventArgs = string.Format("{0};{1};false;false", InitialImageWidth, InitialImageHeight);

            // Act
            toolImageSize.RaisePostBackEvent(raisePostBackEventArgs);

            // Assert
            var imagePath = _shimHttpServerUtility.Instance.MapPath(_imageEditor.ImageURL);

            using (var image = ActivePixToolsTestHelper.LoadImage(imagePath))
            {
                image.ShouldNotBeNull();
            }
        }
예제 #4
0
        public void RaisePostBackEvent_IfDirectWriteSetAsFalse_SavesImageToAlternativePath()
        {
            // Arrange
            var toolImageSize = new ToolImageSize();

            _imageEditor.Toolbar.Tools.Add(toolImageSize);
            _imageEditor.DirectWrite = false;

            // RaisePostBackEvent method eventArgument parameter scheme
            // int width; int height; bool constrainProportions; bool resizeSmaller
            // NOTE: job.ResizeImage() method that called inside of RaisePostBackEvent only resized image if
            // new values are smaller than original. resizeSmaller parameter doesn't work!

            // Args for no changes on image
            var raisePostBackEventArgs = string.Format("{0};{1};false;false", InitialImageWidth, InitialImageHeight);

            // Act
            toolImageSize.RaisePostBackEvent(raisePostBackEventArgs);

            // Assert
            var alternativeDirectoryFilesCount = Directory.GetFiles(ToolImagesAlternativeDirectory).Length;

            alternativeDirectoryFilesCount.ShouldBe(1);
        }