コード例 #1
0
        public void Property_Execute_ReturnsEmpty()
        {
            var command       = new PropertyCommand(_console, LoggerMock.GetLogger <PropertyCommand>().Object);
            var resultMessage = command.Execute();

            Assert.Equal("", resultMessage);
        }
コード例 #2
0
ファイル: CommandTests.cs プロジェクト: spetten/opendiagram
        public void CommandTestProperty()
        {
            //Set up the model
            Model model = new Model();

            model.SetSize(new SizeF(1000, 1000)); //Set the container size so that the shape can be moved

            //Set up the shape element
            Shape shape = new Shape();

            shape.Location  = new PointF(100, 100);
            shape.BackColor = Color.White;
            model.Shapes.Add("Shape1", shape);

            //Set up the controller
            Controller controller = new Controller(model);

            //Set up the command, this stores any values of the shape in a momento
            PropertyCommand command = controller.CommandFactory.CreatePropertyCommand(shape);

            shape.BackColor = Color.Blue;

            //Execute the command
            command.Execute();

            Assert.IsTrue(shape.BackColor.ToArgb() == Color.Blue.ToArgb(), "Property command not executed correctly.");

            command.Undo();
            Assert.IsTrue(shape.BackColor.ToArgb() == Color.White.ToArgb(), "Property command undo not executed correctly.");

            command.Redo();
            Assert.IsTrue(shape.BackColor.ToArgb() == Color.Blue.ToArgb(), "Property command redo not executed correctly.");
        }