public void SingleLineTestUndoRedoCommand()
        {
            // Arrange
            ProjectBlockCollection blocks;
            BlockCommandSupervisor commands;
            BlockTypeSupervisor    blockTypes;
            BlockCommandContext    context;

            SetupMultilineTest(
                out context, out blocks, out blockTypes, out commands, lineCount: 1);

            var command = new DeleteBlockCommand(blocks[0].BlockKey);

            commands.Do(command, context);
            commands.Undo(context);

            // Act
            commands.Redo(context);

            // Assert
            Assert.AreEqual(1, blocks.Count);
            Assert.AreEqual(new BlockPosition(blocks[0], 0), commands.LastPosition);

            const int index = 0;

            Assert.AreEqual("", blocks[index].Text);
            Assert.AreEqual(blockTypes.Paragraph, blocks[index].BlockType);
        }
Ejemplo n.º 2
0
        public void removeMutliBlock()
        {
            List <NodeLocation> newNodes = new List <NodeLocation>();

            foreach (NodeLocation n in myEditor.context.selectedNodes)
            {
                NodeLocation nl = n;
                //determine the opposite face
                int faceId = (int)myEditor.context.currentFace;
                if ((faceId & 0x1) == 1)
                {
                    faceId--;
                }
                else
                {
                    faceId++;
                }

                newNodes.Add(nl.getNeighborLocation((Face)faceId));
                //send delete blocks command
                DeleteBlockCommand cmd = new DeleteBlockCommand(nl);
                myEditor.world.dispatch(cmd);
            }

            myEditor.context.selectedNodes.Clear();
            myEditor.context.selectedNodes.AddRange(newNodes);
        }
        public void TestUndoRedoCommand()
        {
            // Arrange
            ProjectBlockCollection blocks;
            BlockCommandSupervisor commands;
            BlockTypeSupervisor    blockTypes;
            BlockCommandContext    context;

            SetupMultilineTest(out context, out blocks, out blockTypes, out commands);

            var command = new DeleteBlockCommand(blocks[0].BlockKey);

            commands.Do(command, context);
            commands.Undo(context);

            // Act
            commands.Redo(context);

            // Assert
            Assert.AreEqual(3, blocks.Count);
            Assert.AreEqual(new BlockPosition(blocks[0], 0), commands.LastPosition);

            int index = 0;

            Assert.AreEqual("Line 2", blocks[index].Text);
            Assert.AreEqual(blockTypes.Scene, blocks[index].BlockType);

            index++;
            Assert.AreEqual("Line 3", blocks[index].Text);
            Assert.AreEqual(blockTypes.Scene, blocks[index].BlockType);

            index++;
            Assert.AreEqual("Line 4", blocks[index].Text);
            Assert.AreEqual(blockTypes.Scene, blocks[index].BlockType);
        }
Ejemplo n.º 4
0
        public void ShouldReturnValidWhenDeleteCommandIsValid()
        {
            var command = new DeleteBlockCommand();

            command.Id = Guid.NewGuid();
            var handler = new BlockHandler(new BlockRepositoryMock());
            var result  = handler.Handle(command);

            Assert.AreEqual(true, result.Status);
        }
Ejemplo n.º 5
0
 public void Delete(DeleteBlockCommand command)
 {
     _db.Connection().Execute(
         "spDeleteBlock",
         new
     {
         id = command.Id
     },
         commandType: CommandType.StoredProcedure
         );
 }
Ejemplo n.º 6
0
        public void removeBlock()
        {
            //get block selection
            NodeLocation nl = myEditor.context.currentLocation;

            if (nl != null)
            {
                //send create blocks cmd
                DeleteBlockCommand cmd = new DeleteBlockCommand(nl);
                myEditor.world.dispatch(cmd);
            }
        }
        public override LineBufferOperationResults DeleteLines(
            int lineIndex,
            int count)
        {
            using (project.Blocks.AcquireLock(RequestLock.Write))
            {
                Block block   = project.Blocks[lineIndex];
                var   command = new DeleteBlockCommand(block.BlockKey);
                var   context = new BlockCommandContext(project);
                project.Commands.Do(command, context);

                return(GetOperationResults());
            }
        }
Ejemplo n.º 8
0
        public ICommandResult Handle(DeleteBlockCommand command)
        {
            string id = command.Id.ToString();

            if (string.IsNullOrEmpty(id))
            {
                AddNotification("Id", "Identificador inválido");
            }

            if (Invalid)
            {
                return(new CommandResult(false, "Erro ao deletar bloco", Notifications));
            }

            _repository.Delete(command);
            return(new CommandResult(true, "Bloco deletado com sucesso", null));
        }
        public ProjectDeleteLineCommand(
            ProjectLineBuffer lineBuffer,
            Project project,
            LinePosition line)
            : base(project)
        {
            // Save the line for later events.
            this.lineBuffer = lineBuffer;
            this.line       = line;

            // Get a lock on the blocks so we can retrieve information.
            using (project.Blocks.AcquireLock(RequestLock.Read))
            {
                // Create the project command wrapper.
                Block block   = project.Blocks[(int)line];
                var   command = new DeleteBlockCommand(block.BlockKey);

                // Set the command into the adapter.
                Command = command;
            }
        }
 public void Delete(DeleteBlockCommand command)
 {
 }
Ejemplo n.º 11
0
 public ICommandResult Delete(DeleteBlockCommand command)
 {
     return(_handler.Handle(command));
 }