Exemplo n.º 1
0
        public void Execute_ResizeCorrect()
        {
            // Arrange
            var imageDocumentItem = new DocumentItem(new ImageClass("", "", 1, 1));

            _documentMock.Setup(d => d.GetItem(It.IsAny <int>())).Returns(imageDocumentItem);
            ICommand command = new ResizeImageCommand(1, 2, 2, _documentMock.Object);

            // Act
            command.Execute();

            // Assert
            Assert.Equal(2, imageDocumentItem.Image.Width);
            Assert.Equal(2, imageDocumentItem.Image.Height);
        }
Exemplo n.º 2
0
        public void CanCreateCommandAndReplaceItemText()
        {
            var i      = new TestImage();
            int width  = 2;
            int height = 2;

            i.Width  = width;
            i.Height = height;
            Assert.AreEqual(i.Width, width);
            Assert.AreEqual(i.Height, height);

            int newWidth  = 3;
            int newHeight = 10;
            var c         = new ResizeImageCommand(i, newWidth, newHeight);

            c.Execute();
            Assert.AreEqual(i.Width, newWidth);
            Assert.AreEqual(i.Height, newHeight);
        }
Exemplo n.º 3
0
        private void ResizeImageCommandExecutor(string commandParams)
        {
            var argumentsParser = new ArgumentsParser(commandParams);

            if (argumentsParser.NextArgumentsCount != 3)
            {
                throw new MenuException();
            }

            int?position = argumentsParser.GetNextAsInt();
            int?weight   = argumentsParser.GetNextAsInt();
            int?height   = argumentsParser.GetNextAsInt();

            if (position == null || weight == null || height == null)
            {
                throw new MenuException();
            }

            ICommand command = new ResizeImageCommand(position.Value, weight.Value, height.Value, _document);

            command.Execute();
        }
Exemplo n.º 4
0
        public void CanUndoResizeOfImage()
        {
            var i      = new TestImage();
            int width  = 2;
            int height = 2;

            i.Width  = width;
            i.Height = height;
            Assert.AreEqual(i.Width, width);
            Assert.AreEqual(i.Height, height);

            int newWidth  = 3;
            int newHeight = 10;
            var c         = new ResizeImageCommand(i, newWidth, newHeight);

            c.Execute();
            Assert.AreEqual(i.Width, newWidth);
            Assert.AreEqual(i.Height, newHeight);

            c.Unexecute();
            Assert.AreEqual(i.Width, width);
            Assert.AreEqual(i.Height, height);
        }