public void ShouldNotCallToLinkNextElementIfThereIsNoNextElement()
        {
            var track = new Track {
                TrackType = TrackType.Visual
            };

            this.timelineModel.Tracks.Add(track);

            var currentElement = new TimelineElement
            {
                Position    = TimeCode.FromAbsoluteTime(20, this.timelineModel.Duration.FrameRate),
                InPosition  = TimeCode.FromAbsoluteTime(0, this.timelineModel.Duration.FrameRate),
                OutPosition = TimeCode.FromAbsoluteTime(20, this.timelineModel.Duration.FrameRate)
            };

            track.Shots.Add(currentElement);

            ToggleLinkElementCommand command = new ToggleLinkElementCommand(this.timelineModel, track, currentElement, LinkPosition.Out);

            Assert.IsFalse(this.timelineModel.LinkNextElementCalled);

            command.Execute();

            Assert.IsFalse(this.timelineModel.LinkNextElementCalled);
        }
        public void ShouldCallToLinkNextElementIfTheElementsAreUnlinkedWhenUnExecuteCommand()
        {
            var track = new Track {
                TrackType = TrackType.Visual
            };

            this.timelineModel.Tracks.Add(track);

            var currentElement = new TimelineElement
            {
                Position    = TimeCode.FromAbsoluteTime(20, this.timelineModel.Duration.FrameRate),
                InPosition  = TimeCode.FromAbsoluteTime(0, this.timelineModel.Duration.FrameRate),
                OutPosition = TimeCode.FromAbsoluteTime(20, this.timelineModel.Duration.FrameRate)
            };

            var nextElement = new TimelineElement
            {
                Position    = TimeCode.FromAbsoluteTime(40, this.timelineModel.Duration.FrameRate),
                InPosition  = TimeCode.FromAbsoluteTime(0, this.timelineModel.Duration.FrameRate),
                OutPosition = TimeCode.FromAbsoluteTime(20, this.timelineModel.Duration.FrameRate)
            };

            track.Shots.Add(currentElement);
            track.Shots.Add(nextElement);

            this.timelineModel.IsElementLinkedToReturnValue = true;

            this.timelineModel.GetElementAtPositionReturnFunction = () =>
            {
                if (this.timelineModel.GetElementAtPositionPositionArgument == currentElement.Position + currentElement.Duration)
                {
                    return(nextElement);
                }
                else
                {
                    return(null);
                }
            };

            ToggleLinkElementCommand command = new ToggleLinkElementCommand(this.timelineModel, track, currentElement, LinkPosition.Out);

            command.Execute();

            this.timelineModel.IsElementLinkedToReturnValue = false;

            Assert.IsFalse(this.timelineModel.LinkNextElementCalled);

            command.UnExecute();

            Assert.IsTrue(this.timelineModel.LinkNextElementCalled);
        }