Beispiel #1
0
        public void NewCommandShouldClearRedos()
        {
            var command               = Substitute.For <ICommand>();
            var reverseCommand        = Substitute.For <ICommand>();
            var reverseReverseCommand = Substitute.For <ICommand>();

            command.GetReverseCommand().Returns(reverseCommand);
            reverseCommand.GetReverseCommand().Returns(reverseReverseCommand);

            var outline = new Outline();
            var co      = new CommandOutline(outline);

            co.RunCommand(command);
            co.Undo();
            co.RunCommand(Substitute.For <ICommand>());
            co.Redo();
            reverseReverseCommand.Received(0).Do(outline);
        }
Beispiel #2
0
        public void ShouldExecuteTheCommand()
        {
            var command = Substitute.For <ICommand>();
            var outline = new Outline();
            var co      = new CommandOutline(outline);

            co.RunCommand(command);
            command.Received(1).Do(outline);
        }
Beispiel #3
0
        public void UndoShouldExecuteTheReverseCommand()
        {
            var command        = Substitute.For <ICommand>();
            var reverseCommand = Substitute.For <ICommand>();

            command.GetReverseCommand().Returns(reverseCommand);

            var outline = new Outline();
            var co      = new CommandOutline(outline);

            co.RunCommand(command);
            co.Undo();
            reverseCommand.Received(1).Do(outline);
        }
Beispiel #4
0
        public void AddColumnCommandShouldAddColumnToOutline()
        {
            var outline = new Outline();
            var co      = new CommandOutline(outline);
            var col     = new TestColumn("column");

            var columnCount = outline.RootRow.RowValues.Count;

            using (var scope = outline.Monitor())
            {
                co.RunCommand(new AddColumnCommand(col));

                scope.Should().Raise(nameof(Outline.ColumnAdded))
                .WithSender(outline)
                .WithArgs <ColumnAddedEventArgs>(args => args.Column == col);
            }

            outline.RootRow.RowValues.Count.Should().Be(columnCount + 1);
        }